Module: Recls
- Defined in:
- lib/recls/stat.rb,
lib/recls/util.rb,
lib/recls/entry.rb,
lib/recls/flags.rb,
lib/recls/recls.rb,
lib/recls/recls.rb,
lib/recls/foreach.rb,
lib/recls/version.rb,
lib/recls/ximpl/os.rb,
lib/recls/filesearch.rb,
lib/recls/ximpl/unix.rb,
lib/recls/ximpl/util.rb,
lib/recls/ximpl/windows.rb
Defined Under Namespace
Modules: Ximpl Classes: Entry, FileSearch, FileSearchLineEnumerator
Constant Summary collapse
- FILES =
Specifies that files are to be listed
0x00000001- DIRECTORIES =
Specifies that directories are to be listed
0x00000002- LINKS =
Specifies that links are to be listed (and not followed)
0x00000004- DEVICES =
Specifies that devices are to be listed
0x00000008- TYPEMASK =
0x000000ff- SHOW_HIDDEN =
Specifies that hidden items are to be shown and hidden directories are to be searched
0x00000100- DIR_PROGRESS =
0x00001000- STOP_ON_ACCESS_FAILURE =
Causes search to terminate if a directory cannot be entered or an entry’s information cannot be stat()‘d
0x00002000- LINK_COUNT =
0000004000- NODE_INDEX =
0x00008000- RECURSIVE =
0x00010000- DIRECTORY_PARTS =
0x00040000- DETAILS_LATER =
0x00080000- MARK_DIRECTORIES =
0x00200000- SEARCH_THROUGH_LINKS =
Causes sub-directories that are links to be searched; default is not to search through links
0x00100000- WILDCARDS_ALL =
Represents the “all” wildcards string for the ambient operating system
Recls::Ximpl::OS::WILDCARDS_ALL
- PATH_NAME_SEPARATOR =
Recls::Ximpl::OS::PATH_NAME_SEPARATOR
- PATH_SEPARATOR =
Recls::Ximpl::OS::PATH_SEPARATOR
- VERSION =
Current version of the recls.Ruby library
'2.6.4'- VERSION_MAJOR =
:nodoc:
VERSION_PARTS_[0]
- VERSION_MINOR =
:nodoc:
VERSION_PARTS_[1]
- VERSION_REVISION =
:nodoc:
VERSION_PARTS_[2]
Class Method Summary collapse
-
.absolute_path(path) ⇒ Object
Obtains the absolute form of the given path.
-
.canonicalise_path(path) ⇒ Object
Canonicalises the given path, by removing dots (‘.’ and ‘..’) directories.
-
.combine_paths(origin, path, options = {}) ⇒ Object
Combines paths, optionally canonicalising them.
-
.derive_relative_path(origin, path) ⇒ Object
Derives a given path relative to an origin, unless the path is absolute.
- .foreach(*args, &block) ⇒ Object
- .pathNameSeparator ⇒ Object
- .pathSeparator ⇒ Object
-
.stat(path, *args) ⇒ Object
USAGE:.
- .wildcardsAll ⇒ Object
Class Method Details
.absolute_path(path) ⇒ Object
Obtains the absolute form of the given path
45 46 47 48 |
# File 'lib/recls/util.rb', line 45 def self.absolute_path(path) return Recls::Ximpl.absolute_path path end |
.canonicalise_path(path) ⇒ Object
Canonicalises the given path, by removing dots (‘.’ and ‘..’) directories
52 53 54 55 |
# File 'lib/recls/util.rb', line 52 def self.canonicalise_path(path) return Recls::Ximpl.canonicalise_path path end |
.combine_paths(origin, path, options = {}) ⇒ Object
Combines paths, optionally canonicalising them
66 67 68 69 |
# File 'lib/recls/util.rb', line 66 def self.combine_paths(origin, path, ={}) return Recls::Ximpl.combine_paths origin, path, end |
.derive_relative_path(origin, path) ⇒ Object
Derives a given path relative to an origin, unless the path is absolute
59 60 61 62 |
# File 'lib/recls/util.rb', line 59 def self.derive_relative_path(origin, path) return Recls::Ximpl.derive_relative_path origin, path end |
.foreach(*args, &block) ⇒ Object
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 |
# File 'lib/recls/foreach.rb', line 75 def self.foreach(*args, &block) fs = nil case args.length when 1 raise ArgumentError "Single argument must be of type #{Recls::FileSearch}" unless args[0].kind_of? Recls::FileSearch fs = args[0] when 3 fs = Recls::FileSearch.new(args[0], args[1], args[2]) else raise ArgumentError "Function requires single argument (#{Recls::FileSearch}) or three arguments (directory, patterns, flags)" end if block_given? FileSearchLineEnumerator.new(fs).each(block) return nil else return FileSearchLineEnumerator.new(fs) end end |
.pathNameSeparator ⇒ Object
65 66 67 |
# File 'lib/recls/recls.rb', line 65 def self.pathNameSeparator PATH_NAME_SEPARATOR end |
.pathSeparator ⇒ Object
69 70 71 |
# File 'lib/recls/recls.rb', line 69 def self.pathSeparator PATH_SEPARATOR end |
.stat(path, *args) ⇒ Object
USAGE:
- stat(path)
- stat(path, flags)
- stat(path, search_root)
- stat(path, search_root, flags)
- stat(path, flags, search_root)
51 52 53 54 55 56 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/stat.rb', line 51 def self.stat(path, *args) flags = 0 search_root = nil = nil path = File.(path) if path =~ /^~[\\\/]*/ case args.size when 0 ; when 1 case args[0] when ::Integer flags = args[0] when ::String search_root = args[0] else = "argument '#{args[0]}' (#{args[0].class}) not valid" end when 2 if false elsif ::Integer === args[0] && ::String === args[1] flags = args[0] search_root = args[1] elsif ::String === args[0] && ::Integer === args[1] search_root = args[0] flags = args[1] else = "invalid combination of arguments" end else = "too many arguments" end raise ArgumentError, "#{}: Recls.stat() takes one (path), two (path+flags or path+search_root), or three (path+search_root+flags) arguments" if begin Recls::Entry.new(path, Recls::Ximpl::FileStat.stat(path), search_root, flags) rescue Errno::ENOENT => x if 0 != (flags & Recls::DETAILS_LATER) Recls::Entry.new(path, nil, search_root, flags) else nil end end end |
.wildcardsAll ⇒ Object
73 74 75 |
# File 'lib/recls/recls.rb', line 73 def self.wildcardsAll WILDCARDS_ALL end |