Class: Ronin::PostEx::RemoteFile::Stat
- Inherits:
-
Object
- Object
- Ronin::PostEx::RemoteFile::Stat
- Defined in:
- lib/ronin/post_ex/remote_file/stat.rb
Overview
Represents the status information of a remote file. The Stat class
using the fs_stat
or file_stat
method defined by the API object to
request the remote status information.
Supported API Methods
file_stat(fd : Integer) -> Hash[Symbol, Object] | nil
fs_stat(path : String) -> Hash[Symbol, Object] | nil
Instance Attribute Summary collapse
-
#atime ⇒ Time?
readonly
The access time of the file.
-
#blocks ⇒ Integer
readonly
The number of native file-system blocks.
-
#blocksize ⇒ Integer
(also: #blksize)
readonly
The native file-system block size.
-
#ctime ⇒ Time
readonly
The creation time of the file.
-
#gid ⇒ Integer
readonly
The owner's GID of the file.
-
#inode ⇒ Integer
(also: #ino)
readonly
The Inode number.
-
#mode ⇒ Integer
readonly
The mode of the file.
-
#mtime ⇒ Time
readonly
The modification time of the file.
-
#nlinks ⇒ Integer
readonly
The number of hard links to the file.
-
#path ⇒ String
readonly
The path of the file.
-
#size ⇒ Integer
readonly
The size of the file (in bytes).
-
#uid ⇒ Integer
readonly
The owner's UID of the file.
Instance Method Summary collapse
-
#initialize(session, path: nil, fd: nil) ⇒ Stat
constructor
Creates a new File Stat object.
-
#zero? ⇒ Boolean
Determines whether the file has zero size.
Constructor Details
#initialize(session, path: nil, fd: nil) ⇒ Stat
This method requires session
define the fs_stat
API method.
Creates a new File Stat object.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 123 def initialize(session, path: nil, fd: nil) if path unless session.respond_to?(:fs_stat) raise(NotImplementedError,"#{session.inspect} does not define #fs_stat") end elsif fd unless session.respond_to?(:file_stat) raise(NotImplementedError,"#{session.inspect} does not define #file_stat") end else raise(ArgumentError,"#{self.class}#initialize must be given either the path: or fd: keyword argument") end @session = session @path = path.to_s unless (stat = @session.fs_stat(@path)) raise(Errno::ENOENT,"No such file or directory #{@path.dump}") end @size = stat[:size] @blocks = stat[:blocks] @blocksize = stat[:blocksize] @inode = stat[:inode] @nlinks = stat[:nlinks] @mode = stat[:mode] @uid = stat[:uid] @gid = stat[:gid] @atime = stat[:atime] @ctime = stat[:ctime] @mtime = stat[:mtime] end |
Instance Attribute Details
#atime ⇒ Time? (readonly)
The access time of the file.
86 87 88 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 86 def atime @atime end |
#blocks ⇒ Integer (readonly)
The number of native file-system blocks
51 52 53 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 51 def blocks @blocks end |
#blocksize ⇒ Integer (readonly) Also known as: blksize
The native file-system block size.
56 57 58 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 56 def blocksize @blocksize end |
#ctime ⇒ Time (readonly)
The creation time of the file.
91 92 93 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 91 def ctime @ctime end |
#gid ⇒ Integer (readonly)
The owner's GID of the file.
81 82 83 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 81 def gid @gid end |
#inode ⇒ Integer (readonly) Also known as: ino
The Inode number
61 62 63 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 61 def inode @inode end |
#mode ⇒ Integer (readonly)
The mode of the file
71 72 73 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 71 def mode @mode end |
#mtime ⇒ Time (readonly)
The modification time of the file.
96 97 98 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 96 def mtime @mtime end |
#nlinks ⇒ Integer (readonly)
The number of hard links to the file
66 67 68 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 66 def nlinks @nlinks end |
#path ⇒ String (readonly)
The path of the file
41 42 43 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 41 def path @path end |
#size ⇒ Integer (readonly)
The size of the file (in bytes)
46 47 48 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 46 def size @size end |
#uid ⇒ Integer (readonly)
The owner's UID of the file.
76 77 78 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 76 def uid @uid end |
Instance Method Details
#zero? ⇒ Boolean
Determines whether the file has zero size.
167 168 169 |
# File 'lib/ronin/post_ex/remote_file/stat.rb', line 167 def zero? @size == 0 end |