Class: Recls::Entry
Overview
:nodoc:
Instance Attribute Summary collapse
-
#compare_path ⇒ Object
readonly
(String) A normalised form of #path that can be used in comparisons.
-
#directory ⇒ Object
readonly
(String) The entry’s directory (excluding the #drive if on Windows).
-
#directory_parts ⇒ Object
(also: #directoryParts)
readonly
([String]) An array of directory parts, where each part ends in Recls::PATH_NAME_SEPARATOR.
-
#directory_path ⇒ Object
(also: #dirname, #directoryPath)
readonly
(String) The full path of the entry’s directory (taking into account the #drive if on Windows).
-
#drive ⇒ Object
(also: #uncDrive)
readonly
(String) The (Windows) drive.
-
#file_extension ⇒ Object
(also: #extension, #fileExt)
readonly
(String) The entry’s file extension.
-
#file_full_name ⇒ Object
(also: #basename, #file)
readonly
(String) The entry’s file name (combination of #stem + #extension).
-
#file_name_only ⇒ Object
(also: #stem, #fileBaseName, #fileName)
readonly
(String) The entry’s file stem.
-
#file_short_name ⇒ Object
(also: #shortFile)
readonly
(String) The (Windows) short-form of #basename, or
nilif not on Windows. -
#path ⇒ Object
readonly
(String) The full-path of the instance.
-
#search_directory ⇒ Object
(also: #searchDirectory)
readonly
(String) The search directory if specified;
nilotherwise. -
#search_relative_directory ⇒ Object
readonly
(String) The #directory relative to #search_directory;
nilif no search directory specified. -
#search_relative_directory_parts ⇒ Object
readonly
([String]) The #directory_parts relative to #search_directory;
nilif no search directory specified. -
#search_relative_directory_path ⇒ Object
readonly
(String) The #directory_path relative to #search_directory;
nilif no search directory specified. -
#search_relative_path ⇒ Object
(also: #searchRelativePath)
readonly
(String) The #path relative to #search_directory;
nilif no search directory specified. -
#short_path ⇒ Object
readonly
(String) The (Windows) short-form of #path, or
nilif not on Windows.
Instance Method Summary collapse
-
#<=>(rhs) ⇒ Object
compares this instance with rhs.
-
#==(rhs) ⇒ Object
determines whether rhs refers to the same path.
-
#archive? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the archive bit.
-
#compressed? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the compressed bit.
-
#dev ⇒ Object
indicates the device of the given entry.
-
#device? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry is a device.
-
#directory? ⇒ Boolean
(also: #isDirectory)
indicates whether the given entry represents a directory.
-
#encrypted? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the encrypted bit.
-
#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
- WINDOWS-ONLY
-
Indicates whether the entry is normal.
-
#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
- WINDOWS-ONLY
-
Indicates whether the entry has the system bit.
-
#temporary? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the temporary bit.
-
#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
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 101 102 103 104 105 106 107 |
# File 'lib/recls/entry.rb', line 63 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)
(String) A normalised form of #path that can be used in comparisons
113 114 115 |
# File 'lib/recls/entry.rb', line 113 def compare_path @compare_path end |
#directory ⇒ Object (readonly)
(String) The entry’s directory (excluding the #drive if on Windows)
126 127 128 |
# File 'lib/recls/entry.rb', line 126 def directory @directory end |
#directory_parts ⇒ Object (readonly) Also known as: directoryParts
([String]) An array of directory parts, where each part ends in Recls::PATH_NAME_SEPARATOR
128 129 130 |
# File 'lib/recls/entry.rb', line 128 def directory_parts @directory_parts end |
#directory_path ⇒ Object (readonly) Also known as: dirname, directoryPath
(String) The full path of the entry’s directory (taking into account the #drive if on Windows)
123 124 125 |
# File 'lib/recls/entry.rb', line 123 def directory_path @directory_path end |
#drive ⇒ Object (readonly) Also known as: uncDrive
(String) The (Windows) drive. nil if does not exist
120 121 122 |
# File 'lib/recls/entry.rb', line 120 def drive @drive end |
#file_extension ⇒ Object (readonly) Also known as: extension, fileExt
(String) The entry’s file extension
138 139 140 |
# File 'lib/recls/entry.rb', line 138 def file_extension @file_extension end |
#file_full_name ⇒ Object (readonly) Also known as: basename, file
(String) The entry’s file name (combination of #stem + #extension)
130 131 132 |
# File 'lib/recls/entry.rb', line 130 def file_full_name @file_full_name end |
#file_name_only ⇒ Object (readonly) Also known as: stem, fileBaseName, fileName
(String) The entry’s file stem
135 136 137 |
# File 'lib/recls/entry.rb', line 135 def file_name_only @file_name_only end |
#file_short_name ⇒ Object (readonly) Also known as: shortFile
(String) The (Windows) short-form of #basename, or nil if not on Windows
132 133 134 |
# File 'lib/recls/entry.rb', line 132 def file_short_name @file_short_name end |
#path ⇒ Object (readonly)
(String) The full-path of the instance
116 117 118 |
# File 'lib/recls/entry.rb', line 116 def path @path end |
#search_directory ⇒ Object (readonly) Also known as: searchDirectory
(String) The search directory if specified; nil otherwise
141 142 143 |
# File 'lib/recls/entry.rb', line 141 def search_directory @search_directory end |
#search_relative_directory ⇒ Object (readonly)
(String) The #directory relative to #search_directory; nil if no search directory specified
145 146 147 |
# File 'lib/recls/entry.rb', line 145 def search_relative_directory @search_relative_directory end |
#search_relative_directory_parts ⇒ Object (readonly)
([String]) The #directory_parts relative to #search_directory; nil if no search directory specified
149 150 151 |
# File 'lib/recls/entry.rb', line 149 def search_relative_directory_parts @search_relative_directory_parts end |
#search_relative_directory_path ⇒ Object (readonly)
(String) The #directory_path relative to #search_directory; nil if no search directory specified
147 148 149 |
# File 'lib/recls/entry.rb', line 147 def search_relative_directory_path @search_relative_directory_path end |
#search_relative_path ⇒ Object (readonly) Also known as: searchRelativePath
(String) The #path relative to #search_directory; nil if no search directory specified
143 144 145 |
# File 'lib/recls/entry.rb', line 143 def search_relative_path @search_relative_path end |
#short_path ⇒ Object (readonly)
(String) The (Windows) short-form of #path, or nil if not on Windows
118 119 120 |
# File 'lib/recls/entry.rb', line 118 def short_path @short_path end |
Instance Method Details
#<=>(rhs) ⇒ Object
compares this instance with rhs
362 363 364 365 |
# File 'lib/recls/entry.rb', line 362 def <=>(rhs) compare_path <=> rhs.compare_path end |
#==(rhs) ⇒ Object
determines whether rhs refers to the same path
349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/recls/entry.rb', line 349 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
- WINDOWS-ONLY
-
Indicates whether the entry has the archive bit
193 194 195 196 197 198 |
# File 'lib/recls/entry.rb', line 193 def archive? return false if @file_stat.nil? @file_stat.archive? end |
#compressed? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the compressed bit
225 226 227 228 229 230 |
# File 'lib/recls/entry.rb', line 225 def compressed? return false if @file_stat.nil? @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
291 292 293 294 |
# File 'lib/recls/entry.rb', line 291 def dev @dev end |
#device? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry is a device
201 202 203 204 205 206 |
# File 'lib/recls/entry.rb', line 201 def device? return false if @file_stat.nil? @file_stat.device? end |
#directory? ⇒ Boolean Also known as: isDirectory
indicates whether the given entry represents a directory
242 243 244 245 246 247 |
# File 'lib/recls/entry.rb', line 242 def directory? return false if @file_stat.nil? @file_stat.directory? end |
#encrypted? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the encrypted bit
233 234 235 236 237 238 |
# File 'lib/recls/entry.rb', line 233 def encrypted? return false if @file_stat.nil? @file_stat.encrypted? end |
#eql?(rhs) ⇒ Boolean
determines whether rhs is an instance of Entry and refers to the same path
338 339 340 341 342 343 344 345 346 |
# File 'lib/recls/entry.rb', line 338 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
156 157 158 159 160 161 |
# File 'lib/recls/entry.rb', line 156 def exist? return false if @file_stat.nil? not @file_stat.nil? end |
#file? ⇒ Boolean Also known as: isFile
indicates whether the given entry represents a file
250 251 252 253 254 255 |
# File 'lib/recls/entry.rb', line 250 def file? return false if @file_stat.nil? @file_stat.file? end |
#hidden? ⇒ Boolean
indicates whether the given entry is hidden
164 165 166 167 168 169 |
# File 'lib/recls/entry.rb', line 164 def hidden? return false if @file_stat.nil? @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
300 301 302 303 |
# File 'lib/recls/entry.rb', line 300 def ino @ino end |
#isUNC ⇒ Object
85 86 87 88 89 90 |
# File 'lib/recls/obsolete.rb', line 85 def isUNC d = drive d and d.size > 2 end |
#last_access_time ⇒ Object
indicates the last access time of the entry
318 319 320 321 322 323 |
# File 'lib/recls/entry.rb', line 318 def last_access_time return nil if @file_stat.nil? @file_stat.atime end |
#link? ⇒ Boolean
indicates whether the given entry represents a link
258 259 260 261 262 263 |
# File 'lib/recls/entry.rb', line 258 def link? return false if @file_stat.nil? @file_stat.link? end |
#modification_time ⇒ Object Also known as: creationTime
indicates the modification time of the entry
326 327 328 329 330 331 |
# File 'lib/recls/entry.rb', line 326 def modification_time return nil if @file_stat.nil? @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
309 310 311 312 |
# File 'lib/recls/entry.rb', line 309 def nlink @nlink end |
#normal? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry is normal
209 210 211 212 213 214 |
# File 'lib/recls/entry.rb', line 209 def normal? return false if @file_stat.nil? @file_stat.normal? end |
#readonly? ⇒ Boolean Also known as: isReadOnly
indicates whether the given entry is readonly
172 173 174 175 176 177 |
# File 'lib/recls/entry.rb', line 172 def readonly? return false if @file_stat.nil? not @file_stat.writable? end |
#size ⇒ Object
indicates the size of the given entry
277 278 279 280 281 282 |
# File 'lib/recls/entry.rb', line 277 def size return 0 if @file_stat.nil? @file_stat.size end |
#socket? ⇒ Boolean
indicates whether the given entry represents a socket
266 267 268 269 270 271 |
# File 'lib/recls/entry.rb', line 266 def socket? return false if @file_stat.nil? @file_stat.socket? end |
#system? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the system bit
185 186 187 188 189 190 |
# File 'lib/recls/entry.rb', line 185 def system? return false if @file_stat.nil? @file_stat.system? end |
#temporary? ⇒ Boolean
- WINDOWS-ONLY
-
Indicates whether the entry has the temporary bit
217 218 219 220 221 222 |
# File 'lib/recls/entry.rb', line 217 def temporary? return false if @file_stat.nil? @file_stat.temporary? end |
#to_s ⇒ Object
represents the entry as a string (in the form of the full path)
378 379 380 381 |
# File 'lib/recls/entry.rb', line 378 def to_s path end |
#to_str ⇒ Object
represents the entry as a string (in the form of the full path)
385 386 387 388 |
# File 'lib/recls/entry.rb', line 385 def to_str path end |