Class: Recls::Entry
- Inherits:
-
Object
- Object
- Recls::Entry
- Defined in:
- lib/recls/entry.rb,
lib/recls/recls.rb
Instance Attribute Summary collapse
-
#compare_path ⇒ Object
readonly
########################## Name-related attributes.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#directory_parts ⇒ Object
(also: #directoryParts)
readonly
Returns the value of attribute directory_parts.
-
#directory_path ⇒ Object
(also: #dirname, #directoryPath)
readonly
Returns the value of attribute directory_path.
-
#drive ⇒ Object
(also: #uncDrive)
readonly
Returns the value of attribute drive.
-
#file_extension ⇒ Object
(also: #extension, #fileExt)
readonly
Returns the value of attribute file_extension.
-
#file_full_name ⇒ Object
(also: #basename, #file)
readonly
Returns the value of attribute file_full_name.
-
#file_name_only ⇒ Object
(also: #stem, #fileBaseName, #fileName)
readonly
Returns the value of attribute file_name_only.
-
#file_short_name ⇒ Object
(also: #shortFile)
readonly
Returns the value of attribute file_short_name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#search_directory ⇒ Object
(also: #searchDirectory)
readonly
Returns the value of attribute search_directory.
-
#search_relative_directory ⇒ Object
readonly
Returns the value of attribute search_relative_directory.
-
#search_relative_directory_parts ⇒ Object
readonly
Returns the value of attribute search_relative_directory_parts.
-
#search_relative_directory_path ⇒ Object
readonly
Returns the value of attribute search_relative_directory_path.
-
#search_relative_path ⇒ Object
(also: #searchRelativePath)
readonly
Returns the value of attribute search_relative_path.
-
#short_path ⇒ Object
readonly
Returns the value of attribute short_path.
Instance Method Summary collapse
-
#<=>(rhs) ⇒ Object
compares this instance with rhs.
-
#==(rhs) ⇒ Object
determines whether rhs refers to the same path.
- #archive? ⇒ Boolean
- #compressed? ⇒ Boolean
-
#dev ⇒ Object
indicates the device of the given entry.
- #device? ⇒ Boolean
-
#directory? ⇒ Boolean
(also: #isDirectory)
indicates whether the given entry represents a directory.
- #encrypted? ⇒ Boolean
-
#eql?(rhs) ⇒ Boolean
determines whether rhs is an instance of Entry and refers to the same path.
-
#exist? ⇒ Boolean
indicates whether the given entry existed at the time the entry instance was created.
-
#file? ⇒ Boolean
(also: #isFile)
indicates whether the given entry represents a file.
-
#hash ⇒ Object
the hash.
-
#hidden? ⇒ Boolean
indicates whether the given entry is hidden.
-
#initialize(path, file_stat, search_dir, flags) ⇒ Entry
constructor
initialises an entry instance from the given path, file_stat, and search_dir.
-
#ino ⇒ Object
indicates the ino of the given entry.
- #isUNC ⇒ Object
-
#last_access_time ⇒ Object
indicates the last access time of the entry.
-
#link? ⇒ Boolean
indicates whether the given entry represents a link.
-
#modification_time ⇒ Object
(also: #creationTime)
indicates the modification time of the entry.
-
#nlink ⇒ Object
number of links to the given entry.
- #normal? ⇒ Boolean
-
#readonly? ⇒ Boolean
(also: #isReadOnly)
indicates whether the given entry is readonly.
-
#size ⇒ Object
indicates the size of the given entry.
-
#socket? ⇒ Boolean
indicates whether the given entry represents a socket.
- #system? ⇒ Boolean
- #temporary? ⇒ Boolean
-
#to_s ⇒ Object
represents the entry as a string (in the form of the full path).
-
#to_str ⇒ Object
represents the entry as a string (in the form of the full path).
Constructor Details
#initialize(path, file_stat, search_dir, flags) ⇒ Entry
initialises an entry instance from the given path, file_stat, and search_dir
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/recls/entry.rb', line 57 def initialize(path, file_stat, search_dir, flags) @file_stat = file_stat @path = Recls::Ximpl.absolute_path path @short_path = nil @compare_path = Entry.get_compare_path_ @path @hash = @compare_path.hash windows_drive, directory, basename, file_name, file_ext = Recls::Ximpl::Util.split_path @path @drive = windows_drive @directory_path = "#{windows_drive}#{directory}" @directory = directory ? directory : '' @directory_parts = Recls::Ximpl.directory_parts_from_directory directory @file_full_name = basename ? basename : '' @file_short_name = nil @file_name_only = file_name ? file_name : '' @file_extension = file_ext ? file_ext : '' @search_directory = search_dir @search_relative_path = Recls::Ximpl.derive_relative_path search_dir, @path @search_relative_directory_path = Recls::Ximpl.derive_relative_path search_dir, @directory_path @search_relative_directory = @search_relative_directory_path @search_relative_directory_parts = Recls::Ximpl.directory_parts_from_directory @search_relative_directory if 0 != (Recls::MARK_DIRECTORIES & flags) && directory? @path = Recls::Ximpl::Util.append_trailing_slash @path @search_relative_path = Recls::Ximpl::Util.append_trailing_slash @search_relative_path end @dev = @file_stat.dev if @file_stat @ino = @file_stat.ino if @file_stat @nlink = @file_stat.nlink if @file_stat if Recls::Ximpl::OS::OS_IS_WINDOWS && @file_stat @dev = @file_stat.by_handle_information.volume_id @ino = @file_stat.by_handle_information.file_index @nlink = @file_stat.by_handle_information.num_links @short_path = @file_stat.short_path @file_short_name = Recls::Ximpl::Util.split_path(@short_path)[2] else end end |
Instance Attribute Details
#compare_path ⇒ Object (readonly)
########################## Name-related attributes
105 106 107 |
# File 'lib/recls/entry.rb', line 105 def compare_path @compare_path end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
112 113 114 |
# File 'lib/recls/entry.rb', line 112 def directory @directory end |
#directory_parts ⇒ Object (readonly) Also known as: directoryParts
Returns the value of attribute directory_parts.
113 114 115 |
# File 'lib/recls/entry.rb', line 113 def directory_parts @directory_parts end |
#directory_path ⇒ Object (readonly) Also known as: dirname, directoryPath
Returns the value of attribute directory_path.
110 111 112 |
# File 'lib/recls/entry.rb', line 110 def directory_path @directory_path end |
#drive ⇒ Object (readonly) Also known as: uncDrive
Returns the value of attribute drive.
109 110 111 |
# File 'lib/recls/entry.rb', line 109 def drive @drive end |
#file_extension ⇒ Object (readonly) Also known as: extension, fileExt
Returns the value of attribute file_extension.
119 120 121 |
# File 'lib/recls/entry.rb', line 119 def file_extension @file_extension end |
#file_full_name ⇒ Object (readonly) Also known as: basename, file
Returns the value of attribute file_full_name.
114 115 116 |
# File 'lib/recls/entry.rb', line 114 def file_full_name @file_full_name end |
#file_name_only ⇒ Object (readonly) Also known as: stem, fileBaseName, fileName
Returns the value of attribute file_name_only.
117 118 119 |
# File 'lib/recls/entry.rb', line 117 def file_name_only @file_name_only end |
#file_short_name ⇒ Object (readonly) Also known as: shortFile
Returns the value of attribute file_short_name.
115 116 117 |
# File 'lib/recls/entry.rb', line 115 def file_short_name @file_short_name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
107 108 109 |
# File 'lib/recls/entry.rb', line 107 def path @path end |
#search_directory ⇒ Object (readonly) Also known as: searchDirectory
Returns the value of attribute search_directory.
121 122 123 |
# File 'lib/recls/entry.rb', line 121 def search_directory @search_directory end |
#search_relative_directory ⇒ Object (readonly)
Returns the value of attribute search_relative_directory.
123 124 125 |
# File 'lib/recls/entry.rb', line 123 def search_relative_directory @search_relative_directory end |
#search_relative_directory_parts ⇒ Object (readonly)
Returns the value of attribute search_relative_directory_parts.
125 126 127 |
# File 'lib/recls/entry.rb', line 125 def search_relative_directory_parts @search_relative_directory_parts end |
#search_relative_directory_path ⇒ Object (readonly)
Returns the value of attribute search_relative_directory_path.
124 125 126 |
# File 'lib/recls/entry.rb', line 124 def search_relative_directory_path @search_relative_directory_path end |
#search_relative_path ⇒ Object (readonly) Also known as: searchRelativePath
Returns the value of attribute search_relative_path.
122 123 124 |
# File 'lib/recls/entry.rb', line 122 def search_relative_path @search_relative_path end |
#short_path ⇒ Object (readonly)
Returns the value of attribute short_path.
108 109 110 |
# File 'lib/recls/entry.rb', line 108 def short_path @short_path end |
Instance Method Details
#<=>(rhs) ⇒ Object
compares this instance with rhs
297 298 299 300 |
# File 'lib/recls/entry.rb', line 297 def <=>(rhs) compare_path <=> rhs.compare_path end |
#==(rhs) ⇒ Object
determines whether rhs refers to the same path
284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/recls/entry.rb', line 284 def ==(rhs) case rhs when String return compare_path == Entry.get_compare_path_(rhs) when self.class return compare_path == rhs.compare_path else return false end end |
#archive? ⇒ Boolean
159 160 161 162 |
# File 'lib/recls/entry.rb', line 159 def archive? @file_stat.archive? end |
#compressed? ⇒ Boolean
179 180 181 182 |
# File 'lib/recls/entry.rb', line 179 def compressed? @file_stat.compressed? end |
#dev ⇒ Object
indicates the device of the given entry
On Windows, this will be 0 if the entry cannot be opened
230 231 232 233 |
# File 'lib/recls/entry.rb', line 230 def dev @dev end |
#device? ⇒ Boolean
164 165 166 167 |
# File 'lib/recls/entry.rb', line 164 def device? @file_stat.device? end |
#directory? ⇒ Boolean Also known as: isDirectory
indicates whether the given entry represents a directory
191 192 193 194 |
# File 'lib/recls/entry.rb', line 191 def directory? @file_stat.directory? end |
#encrypted? ⇒ Boolean
184 185 186 187 |
# File 'lib/recls/entry.rb', line 184 def encrypted? @file_stat.encrypted? end |
#eql?(rhs) ⇒ Boolean
determines whether rhs is an instance of Entry and refers to the same path
273 274 275 276 277 278 279 280 281 |
# File 'lib/recls/entry.rb', line 273 def eql?(rhs) case rhs when self.class return compare_path == rhs.compare_path else return false end end |
#exist? ⇒ Boolean
indicates whether the given entry existed at the time the entry instance was created
132 133 134 135 |
# File 'lib/recls/entry.rb', line 132 def exist? not @file_stat.nil? end |
#file? ⇒ Boolean Also known as: isFile
indicates whether the given entry represents a file
197 198 199 200 |
# File 'lib/recls/entry.rb', line 197 def file? @file_stat.file? end |
#hash ⇒ Object
the hash
303 304 305 306 |
# File 'lib/recls/entry.rb', line 303 def hash @hash end |
#hidden? ⇒ Boolean
indicates whether the given entry is hidden
138 139 140 141 |
# File 'lib/recls/entry.rb', line 138 def hidden? @file_stat.hidden? end |
#ino ⇒ Object
indicates the ino of the given entry
On Windows, this will be 0 if the entry cannot be opened
239 240 241 242 |
# File 'lib/recls/entry.rb', line 239 def ino @ino end |
#isUNC ⇒ Object
101 102 103 104 105 106 |
# File 'lib/recls/recls.rb', line 101 def isUNC d = drive d and d.size > 2 end |
#last_access_time ⇒ Object
indicates the last access time of the entry
257 258 259 260 |
# File 'lib/recls/entry.rb', line 257 def last_access_time @file_stat.atime end |
#link? ⇒ Boolean
indicates whether the given entry represents a link
203 204 205 206 |
# File 'lib/recls/entry.rb', line 203 def link? @file_stat.link? end |
#modification_time ⇒ Object Also known as: creationTime
indicates the modification time of the entry
263 264 265 266 |
# File 'lib/recls/entry.rb', line 263 def modification_time @file_stat.mtime end |
#nlink ⇒ Object
number of links to the given entry
On Windows, this will be 0 if the entry cannot be opened
248 249 250 251 |
# File 'lib/recls/entry.rb', line 248 def nlink @nlink end |
#normal? ⇒ Boolean
169 170 171 172 |
# File 'lib/recls/entry.rb', line 169 def normal? @file_stat.normal? end |
#readonly? ⇒ Boolean Also known as: isReadOnly
indicates whether the given entry is readonly
144 145 146 147 |
# File 'lib/recls/entry.rb', line 144 def readonly? not @file_stat.writable? end |
#size ⇒ Object
indicates the size of the given entry
218 219 220 221 |
# File 'lib/recls/entry.rb', line 218 def size @file_stat.size end |
#socket? ⇒ Boolean
indicates whether the given entry represents a socket
209 210 211 212 |
# File 'lib/recls/entry.rb', line 209 def socket? @file_stat.socket? end |
#system? ⇒ Boolean
154 155 156 157 |
# File 'lib/recls/entry.rb', line 154 def system? @file_stat.system? end |
#temporary? ⇒ Boolean
174 175 176 177 |
# File 'lib/recls/entry.rb', line 174 def temporary? @file_stat.temporary? end |
#to_s ⇒ Object
represents the entry as a string (in the form of the full path)
313 314 315 316 |
# File 'lib/recls/entry.rb', line 313 def to_s path end |
#to_str ⇒ Object
represents the entry as a string (in the form of the full path)
320 321 322 323 |
# File 'lib/recls/entry.rb', line 320 def to_str path end |