class Recls::Entry
A file-system entry
Attributes
(String) A normalised form of path
that can be used in comparisons
(String) The entry's directory (excluding the drive
if on Windows)
([String]) An array of directory parts, where each part ends in Recls::PATH_NAME_SEPARATOR
(String) The full path of the entry's directory (taking into account the drive
if on Windows)
(String) The full path of the entry's directory (taking into account the drive
if on Windows)
(String) The (Windows) drive. nil
if does not exist
(String) The entry's file extension
(String) The entry's file extension
(String) The entry's file stem
(String) The (Windows) short-form of basename
, or nil
if not on Windows
(String) The full-path of the instance
(String) The search directory if specified; nil
otherwise
(String) The directory
relative to search_directory
; nil
if no search directory specified
([String]) The directory_parts
relative to search_directory
; nil
if no search directory specified
(String) The directory_path
relative to search_directory
; nil
if no search directory specified
(String) The path
relative to search_directory
; nil
if no search directory specified
(String) The (Windows) short-form of path
, or nil
if not on Windows
(String) The entry's file stem
Public Class Methods
initialises an entry instance from the given path, file_stat, and search_dir
# File lib/recls/entry.rb, line 65 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
Private Class Methods
@!visibility private
# File lib/recls/entry.rb, line 57 def self.get_compare_path_(path) return path.upcase if Recls::Ximpl::OS::OS_IS_WINDOWS path end
Public Instance Methods
compares this instance with rhs
# File lib/recls/entry.rb, line 366 def <=>(rhs) compare_path <=> rhs.compare_path end
determines whether rhs refers to the same path
# File lib/recls/entry.rb, line 353 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
- WINDOWS-ONLY
-
Indicates whether the entry has the archive bit
# File lib/recls/entry.rb, line 195 def archive? return false if @file_stat.nil? @file_stat.archive? end
- WINDOWS-ONLY
-
Indicates whether the entry has the compressed bit
# File lib/recls/entry.rb, line 227 def compressed? return false if @file_stat.nil? @file_stat.compressed? end
indicates the device of the given entry
On Windows, this will be 0 if the entry cannot be opened
# File lib/recls/entry.rb, line 295 def dev @dev end
- WINDOWS-ONLY
-
Indicates whether the entry is a device
# File lib/recls/entry.rb, line 203 def device? return false if @file_stat.nil? @file_stat.device? end
indicates whether the given entry represents a directory
# File lib/recls/entry.rb, line 244 def directory? return false if @file_stat.nil? @file_stat.directory? end
- WINDOWS-ONLY
-
Indicates whether the entry has the encrypted bit
# File lib/recls/entry.rb, line 235 def encrypted? return false if @file_stat.nil? @file_stat.encrypted? end
determines whether rhs is an instance of Entry and refers to the same path
# File lib/recls/entry.rb, line 342 def eql?(rhs) case rhs when self.class return compare_path == rhs.compare_path else return false end end
indicates whether the given entry existed at the time the entry instance was created
# File lib/recls/entry.rb, line 158 def exist? return false if @file_stat.nil? not @file_stat.nil? end
indicates whether the given entry represents a file
# File lib/recls/entry.rb, line 254 def file? return false if @file_stat.nil? @file_stat.file? end
the hash
# File lib/recls/entry.rb, line 372 def hash @hash end
indicates the ino of the given entry
On Windows, this will be 0 if the entry cannot be opened
# File lib/recls/entry.rb, line 304 def ino @ino end
indicates the last access time of the entry
# File lib/recls/entry.rb, line 322 def last_access_time return nil if @file_stat.nil? @file_stat.atime end
indicates whether the given entry represents a link
# File lib/recls/entry.rb, line 262 def link? return false if @file_stat.nil? @file_stat.link? end
indicates the modification time of the entry
# File lib/recls/entry.rb, line 330 def modification_time return nil if @file_stat.nil? @file_stat.mtime end
number of links to the given entry
On Windows, this will be 0 if the entry cannot be opened
# File lib/recls/entry.rb, line 313 def nlink @nlink end
- WINDOWS-ONLY
-
Indicates whether the entry is normal
# File lib/recls/entry.rb, line 211 def normal? return false if @file_stat.nil? @file_stat.normal? end
indicates whether the given entry is readonly
# File lib/recls/entry.rb, line 174 def readonly? return false if @file_stat.nil? not @file_stat.writable? end
indicates the size of the given entry
# File lib/recls/entry.rb, line 281 def size return 0 if @file_stat.nil? @file_stat.size end
indicates whether the given entry represents a socket
# File lib/recls/entry.rb, line 270 def socket? return false if @file_stat.nil? @file_stat.socket? end
- WINDOWS-ONLY
-
Indicates whether the entry has the system bit
# File lib/recls/entry.rb, line 187 def system? return false if @file_stat.nil? @file_stat.system? end
- WINDOWS-ONLY
-
Indicates whether the entry has the temporary bit
# File lib/recls/entry.rb, line 219 def temporary? return false if @file_stat.nil? @file_stat.temporary? end
represents the entry as a string (in the form of the full path)
# File lib/recls/entry.rb, line 382 def to_s path end
represents the entry as a string (in the form of the full path)
# File lib/recls/entry.rb, line 389 def to_str path end