Class: Ftpd::FileInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/ftpd/file_info.rb

Overview

Information about a file object (file, directory, symlink, etc.)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ FileInfo

Create a new instance. See the various attributes for argument details.

Options Hash (opts):

  • :ftype (String)

    The file type

  • :group (String)

    The group name

  • :identifier (String)

    The object's identifier

  • :mode (Integer)

    The mode bits

  • :mtime (Time)

    The modification time

  • :nlink (Integer)

    The number of hard links

  • :owner (String)

    The owner name

  • :size (Integer)

    The size

  • :path (String)

    The object's path


89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ftpd/file_info.rb', line 89

def initialize(opts)
  @ftype = opts[:ftype]
  @group = opts[:group]
  @identifier = opts[:identifier]
  @mode = opts[:mode]
  @mtime = opts[:mtime]
  @nlink = opts[:nlink]
  @owner = opts[:owner]
  @path = opts[:path]
  @size = opts[:size]
end

Instance Attribute Details

#ftypeString (readonly)

One of:

  • 'file'

  • 'directory'

  • 'characterSpecial'

  • 'blockSpecial'

  • 'fifo'

  • 'link'

  • 'socket'

  • 'unknown'


18
19
20
# File 'lib/ftpd/file_info.rb', line 18

def ftype
  @ftype
end

#groupString (readonly)


22
23
24
# File 'lib/ftpd/file_info.rb', line 22

def group
  @group
end

#identifierString (readonly)

This uniquely identifies the file: Two objects with the same identifier are expected to refer to the same file or directory.

On a disk file system, might be dev.inode, e.g. “8388621.48598”

This is optional and does not have to be set. If set, it is used in EPLF output.


73
74
75
# File 'lib/ftpd/file_info.rb', line 73

def identifier
  @identifier
end

#modeInteger (readonly)

The bits are:

* 0 - others have execute permission
* 1 - others have write permission
* 2 - others have read permission
* 3 - group has execute permission
* 4 - group has write permission
* 5 - group has read permission
* 6 - owner has execute permission
* 7 - owner has write permission
* 8 - owner has read permission
* 9 - sticky bit
* 10 - set-group-ID bit
* 11 - set UID bit

Other bits may be present; they are ignored


40
41
42
# File 'lib/ftpd/file_info.rb', line 40

def mode
  @mode
end

#mtimeTime (readonly)


44
45
46
# File 'lib/ftpd/file_info.rb', line 44

def mtime
  @mtime
end

48
49
50
# File 'lib/ftpd/file_info.rb', line 48

def nlink
  @nlink
end

#ownerString (readonly)


52
53
54
# File 'lib/ftpd/file_info.rb', line 52

def owner
  @owner
end

#pathString (readonly)


60
61
62
# File 'lib/ftpd/file_info.rb', line 60

def path
  @path
end

#sizeInteger (readonly)


56
57
58
# File 'lib/ftpd/file_info.rb', line 56

def size
  @size
end

Instance Method Details

#directory?Boolean


109
110
111
# File 'lib/ftpd/file_info.rb', line 109

def directory?
  @ftype == 'directory'
end

#file?Boolean


103
104
105
# File 'lib/ftpd/file_info.rb', line 103

def file?
  @ftype == 'file'
end