Class: Archiverb::Stat

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/archiverb/stat.rb

Constant Summary collapse

@@reqdatrs =
[ :dev    , :dev_major , :dev_minor  , :ino        , :mode  , :nlink   ,
  :gid    , :uid       , :rdev_major , :rdev_minor , :size  , :blksize ,
  :blocks , :atime     , :mtime      , :ctime      , :ftype , :pipe?   ,
  :rdev   , :symlink?
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, start = {}) ⇒ Stat

Returns a new instance of Stat.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/archiverb/stat.rb', line 9

def initialize(io, start = {})
  return super(Hash[@@reqdatrs.map{|m| [m, def_v(m)]}].merge(io)) if io.is_a?(Hash)
  return super(stat_hash(io).merge(start)) if io.is_a?(::File::Stat)

  statm = [:lstat, :stat].find{|m| io.respond_to?(m)}
  return super(Hash[@@reqdatrs.map{|m| [m, def_v(m)]}].merge(stat_hash(io)).merge(start)) if statm.nil?

  hash = stat_hash(io.send(statm))
  hash[:readlink] = ::File.readlink(io) if hash[:symlink?]
  return super(hash.merge(start))
end

Instance Attribute Details

#gnameObject

ASCII representation of the owner and group of the file respectively. In TAR, if found, the user and group IDs are used rather than the values in the uid and gid fields.



24
25
26
# File 'lib/archiverb/stat.rb', line 24

def gname
  @gname
end

#unameObject

ASCII representation of the owner and group of the file respectively. In TAR, if found, the user and group IDs are used rather than the values in the uid and gid fields.



24
25
26
# File 'lib/archiverb/stat.rb', line 24

def uname
  @uname
end