Method: FileTransfer::Ftp#list

Defined in:
lib/file_transfer/ftp.rb

#list(dir, options = {}) ⇒ Array<String>

Gets directory listing from SFTP server

Parameters:

  • dir (String)

    remote directory

  • options (Hash<Symbol,String>) (defaults to: {})

    additional options

Returns:

  • (Array<String>)

    listing with all file paths



20
21
22
23
24
25
26
27
28
29
# File 'lib/file_transfer/ftp.rb', line 20

def list(dir, options = {})
  open_connection(60) do
    ftp.chdir dir
    result = ftp.nlst
    if options.has_key? :file_type
      result = result.select { |file_name| file_name.end_with? options[:file_type] }
    end
    result
  end
end