Module: Ftpd::DiskFileSystem::Read

Includes:
TranslateExceptions
Included in:
Ftpd::DiskFileSystem, ReadOnlyDiskFileSystem
Defined in:
lib/ftpd/disk_file_system.rb

Overview

DiskFileSystem mixin providing file reading

Instance Method Summary collapse

Methods included from TranslateExceptions

included, #translate_exception

Instance Method Details

#read(ftp_path) {|io| ... } ⇒ Object

Read a file from disk. Called for:

  • RETR

If missing, then these commands are not supported.

Parameters:

  • ftp_path (String)

    The virtual path

Yields:

  • (io)

    Passes an IO object to the block



133
134
135
136
137
138
139
140
# File 'lib/ftpd/disk_file_system.rb', line 133

def read(ftp_path, &block)
  io = File.open(expand_ftp_path(ftp_path), 'rb')
  begin
    yield(io)
  ensure
    io.close
  end
end