Class: FTPMVC::Ftpd::FileSystem

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/ftpmvc/ftpd/file_system.rb

Instance Method Summary collapse

Methods included from Logger

#logger

Constructor Details

#initialize(application) ⇒ FileSystem

Returns a new instance of FileSystem.



9
10
11
# File 'lib/ftpmvc/ftpd/file_system.rb', line 9

def initialize(application)
  @application = application
end

Instance Method Details

#accessible?(path) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/ftpmvc/ftpd/file_system.rb', line 33

def accessible?(path)
  logger.debug { "FTPMVC::Ftpd::FileSystem#accessible?(#{path})" }
  true
end

#dir(path) ⇒ Object



13
14
15
16
# File 'lib/ftpmvc/ftpd/file_system.rb', line 13

def dir(path)
  logger.debug { "FTPMVC::Ftpd::FileSystem#dir(#{path})" }
  @application.index(path.gsub('/*', '')).map { |node| ::File.join(path, node.name) }
end

#directory?(path) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/ftpmvc/ftpd/file_system.rb', line 18

def directory?(path)
  logger.debug { "FTPMVC::Ftpd::FileSystem#directory?(#{path})" }
  @application.directory?(path.gsub('/*', ''))
end

#exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/ftpmvc/ftpd/file_system.rb', line 38

def exists?(path)
  logger.debug { "FTPMVC::Ftpd::FileSystem#exists?(#{path})" }
  @application.exists?(path)
end

#file_info(path) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ftpmvc/ftpd/file_system.rb', line 43

def file_info(path)
  logger.debug { "FTPMVC::Ftpd::FileSystem#file_info(#{path})" }
  ::Ftpd::FileInfo.new(
    :ftype => directory?(path) ? 'directory' : 'file',
    :group => 'nogroup',
    :mode => directory?(path) ? 0750 : 0640,
    :mtime => Time.now,
    :nlink => 33,
    :owner => 'nobody',
    :path => path,
    :size => 0)
end

#read(path) {|@application.get(path)| ... } ⇒ Object

Yields:

  • (@application.get(path))


23
24
25
26
# File 'lib/ftpmvc/ftpd/file_system.rb', line 23

def read(path)
  logger.debug { "FTPMVC::Ftpd::FileSystem#read(#{path})" }
  yield @application.get(path)
end

#write(path, stream) ⇒ Object



28
29
30
31
# File 'lib/ftpmvc/ftpd/file_system.rb', line 28

def write(path, stream)
  logger.debug { "FTPMVC::Ftpd::FileSystem#write(#{path}, ...)" }
  @application.put(path, stream)
end