recls-ruby 2.13.0 → 2.13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +50 -47
- data/examples/find_files_and_directories.md +4 -4
- data/examples/find_files_and_directories.rb +3 -3
- data/lib/recls/api.rb +28 -18
- data/lib/recls/combine_paths_1.rb +2 -5
- data/lib/recls/combine_paths_2plus.rb +2 -5
- data/lib/recls/entry.rb +26 -36
- data/lib/recls/file_search.rb +7 -9
- data/lib/recls/flags.rb +9 -13
- data/lib/recls/foreach.rb +7 -10
- data/lib/recls/obsolete.rb +2 -7
- data/lib/recls/recls.rb +16 -15
- data/lib/recls/stat.rb +16 -19
- data/lib/recls/util.rb +11 -14
- data/lib/recls/version.rb +2 -5
- data/lib/recls/ximpl/os.rb +3 -6
- data/lib/recls/ximpl/unix.rb +6 -15
- data/lib/recls/ximpl/util.rb +4 -8
- data/lib/recls/ximpl/windows.rb +2 -6
- data/test/scratch/test_foreach.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e34f60c35aebc4cf9cb1e217c1e7cf3e0211abee3eddb8e6306daa601c36461
|
4
|
+
data.tar.gz: 888951b3419b4be2b453449a3f25b0ee725e78539449caf469c767bbc329fbd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0756416a3dc1d95aae37a46e7d3db1bbea1347e7b0cc369088910662698361dcedf718da31d818b976fc78b342766dd155c969fab8593f90e6c644e8cc44d04
|
7
|
+
data.tar.gz: 85291a5a45c3b430f92fbed82f9033bc53d524fa67dde8fd40b6f85581032b625c0756e944ab57fb6a74c3b9f60e92264f05dd7cdd606f2e5ecd8f61b1cd774e
|
data/README.md
CHANGED
@@ -1,32 +1,37 @@
|
|
1
|
-
# recls.Ruby
|
1
|
+
# recls.Ruby <!-- omit in toc -->
|
2
2
|
|
3
|
-
**rec
|
3
|
+
**rec**-ursive **ls**, for Ruby
|
4
4
|
|
5
5
|
[](https://badge.fury.io/rb/recls-ruby)
|
6
6
|
|
7
7
|
|
8
8
|
## Introduction
|
9
9
|
|
10
|
-
**recls** stands for **rec
|
10
|
+
**recls** stands for **rec**-ursive **ls**. The first recls library was a C
|
11
11
|
library with a C++ wrapper. There have been several implementations in other
|
12
12
|
languages. **recls.Ruby** is the Ruby version.
|
13
13
|
|
14
14
|
|
15
|
-
## Table of Contents
|
15
|
+
## Table of Contents <!-- omit in toc -->
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
- [Introduction](#introduction)
|
18
|
+
- [Installation](#installation)
|
19
|
+
- [Components](#components)
|
20
|
+
- [The ``Recls`` module](#the-recls-module)
|
21
|
+
- [The ``Recls::Entry`` class](#the-reclsentry-class)
|
22
|
+
- [Examples](#examples)
|
23
|
+
- [Project Information](#project-information)
|
24
|
+
- [Where to get help](#where-to-get-help)
|
25
|
+
- [Contribution guidelines](#contribution-guidelines)
|
26
|
+
- [Dependencies](#dependencies)
|
27
|
+
- [Development dependencies](#development-dependencies)
|
28
|
+
- [Dependents](#dependents)
|
29
|
+
- [Related projects](#related-projects)
|
30
|
+
- [License](#license)
|
31
|
+
- [Compatibility](#compatibility)
|
22
32
|
|
23
33
|
|
24
|
-
##
|
25
|
-
|
26
|
-
T.B.C.
|
27
|
-
|
28
|
-
|
29
|
-
## Installation & usage
|
34
|
+
## Installation
|
30
35
|
|
31
36
|
Install using `gem install recls-ruby` or add it to your `Gemfile`.
|
32
37
|
|
@@ -57,26 +62,24 @@ module Recls
|
|
57
62
|
# ##########################
|
58
63
|
# Name-related attributes
|
59
64
|
|
60
|
-
# (+String+) A normalised form of
|
65
|
+
# (+String+) A normalised form of {.path} that can be used in comparisons
|
61
66
|
attr_reader :compare_path
|
62
|
-
|
63
67
|
# (+String+) The full-path of the instance
|
64
68
|
attr_reader :path
|
65
|
-
# (+String+) The (Windows) short-form of
|
69
|
+
# (+String+) The (Windows) short-form of {.path}, or +nil+ if not on Windows
|
66
70
|
attr_reader :short_path
|
67
71
|
# (+String+) The (Windows) drive. +nil+ if does not exist
|
68
72
|
attr_reader :drive
|
69
|
-
# (+String+) The full path of the entry's directory (taking into account the
|
70
|
-
# #drive if on Windows)
|
73
|
+
# (+String+) The full path of the entry's directory (taking into account the {.drive} if on Windows)
|
71
74
|
attr_reader :directory_path
|
72
75
|
alias_method :dirname, :directory_path
|
73
|
-
# (+String+) The entry's directory (excluding the
|
76
|
+
# (+String+) The entry's directory (excluding the {.drive} if on Windows)
|
74
77
|
attr_reader :directory
|
75
|
-
# (+[ String ]+) An array of directory parts, where each part ends in Recls::PATH_NAME_SEPARATOR
|
78
|
+
# ( +[+ +String+ +]+ ) An array of directory parts, where each part ends in {Recls::PATH_NAME_SEPARATOR}
|
76
79
|
attr_reader :directory_parts
|
77
|
-
# (+String+) The entry's file name (combination of
|
80
|
+
# (+String+) The entry's file name (combination of {.stem} + {.extension})
|
78
81
|
attr_reader :file_full_name
|
79
|
-
# (+String+) The (Windows) short-form of
|
82
|
+
# (+String+) The (Windows) short-form of {.basename}, or +nil+ if not on Windows
|
80
83
|
attr_reader :file_short_name
|
81
84
|
alias_method :basename, :file_full_name
|
82
85
|
# (+String+) The entry's file stem
|
@@ -87,13 +90,13 @@ module Recls
|
|
87
90
|
alias_method :extension, :file_extension
|
88
91
|
# (+String+) The search directory if specified; +nil+ otherwise
|
89
92
|
attr_reader :search_directory
|
90
|
-
# (+String+) The
|
93
|
+
# (+String+) The +#path+ relative to {.search_directory}; +nil+ if no search directory specified
|
91
94
|
attr_reader :search_relative_path
|
92
|
-
# (+String+) The
|
95
|
+
# (+String+) The +#directory+ relative to {.search_directory}; +nil+ if no search directory specified
|
93
96
|
attr_reader :search_relative_directory
|
94
|
-
# (+String+) The
|
97
|
+
# (+String+) The +#directory_path+ relative to {.search_directory}; +nil+ if no search directory specified
|
95
98
|
attr_reader :search_relative_directory_path
|
96
|
-
# (+[ String ]+) The
|
99
|
+
# ( +[+ +String+ +]+ ) The +#directory_parts+ relative to {.search_directory}; +nil+ if no search directory specified
|
97
100
|
attr_reader :search_relative_directory_parts
|
98
101
|
|
99
102
|
# ##########################
|
@@ -117,37 +120,37 @@ module Recls
|
|
117
120
|
|
118
121
|
if Recls::Ximpl::OS::OS_IS_WINDOWS
|
119
122
|
|
120
|
-
#
|
123
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *system* bit
|
121
124
|
def system?
|
122
125
|
. . .
|
123
126
|
end
|
124
127
|
|
125
|
-
#
|
128
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *archive* bit
|
126
129
|
def archive?
|
127
130
|
. . .
|
128
131
|
end
|
129
132
|
|
130
|
-
#
|
133
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry is a device
|
131
134
|
def device?
|
132
135
|
. . .
|
133
136
|
end
|
134
137
|
|
135
|
-
#
|
138
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry is *normal*
|
136
139
|
def normal?
|
137
140
|
. . .
|
138
141
|
end
|
139
142
|
|
140
|
-
#
|
143
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *temporary* bit
|
141
144
|
def temporary?
|
142
145
|
. . .
|
143
146
|
end
|
144
147
|
|
145
|
-
#
|
148
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *compressed* bit
|
146
149
|
def compressed?
|
147
150
|
. . .
|
148
151
|
end
|
149
152
|
|
150
|
-
#
|
153
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *encrypted* bit
|
151
154
|
def encrypted?
|
152
155
|
. . .
|
153
156
|
end
|
@@ -188,24 +191,21 @@ module Recls
|
|
188
191
|
|
189
192
|
# indicates the device of the given entry
|
190
193
|
#
|
191
|
-
# On Windows, this will be 0 if the entry cannot be
|
192
|
-
# opened
|
194
|
+
# On Windows, this will be 0 if the entry cannot be opened
|
193
195
|
def dev
|
194
196
|
. . .
|
195
197
|
end
|
196
198
|
|
197
199
|
# indicates the ino of the given entry
|
198
200
|
#
|
199
|
-
# On Windows, this will be 0 if the entry cannot be
|
200
|
-
# opened
|
201
|
+
# On Windows, this will be 0 if the entry cannot be opened
|
201
202
|
def ino
|
202
203
|
. . .
|
203
204
|
end
|
204
205
|
|
205
206
|
# number of links to the given entry
|
206
207
|
#
|
207
|
-
# On Windows, this will be 0 if the entry cannot be
|
208
|
-
# opened
|
208
|
+
# On Windows, this will be 0 if the entry cannot be opened
|
209
209
|
def nlink
|
210
210
|
. . .
|
211
211
|
end
|
@@ -226,8 +226,8 @@ module Recls
|
|
226
226
|
# ##########################
|
227
227
|
# Comparison
|
228
228
|
|
229
|
-
# determines whether rhs is an instance of Entry and
|
230
|
-
#
|
229
|
+
# determines whether rhs is an instance of {Recls::Entry} and refers to
|
230
|
+
# the same path
|
231
231
|
def eql?(rhs)
|
232
232
|
. . .
|
233
233
|
end
|
@@ -250,14 +250,12 @@ module Recls
|
|
250
250
|
# ##########################
|
251
251
|
# Conversion
|
252
252
|
|
253
|
-
# represents the entry as a string (in the form of
|
254
|
-
# the full path)
|
253
|
+
# represents the entry as a string (in the form of the full path)
|
255
254
|
def to_s
|
256
255
|
. . .
|
257
256
|
end
|
258
257
|
|
259
|
-
# represents the entry as a string (in the form of
|
260
|
-
# the full path)
|
258
|
+
# represents the entry as a string (in the form of the full path)
|
261
259
|
def to_str
|
262
260
|
. . .
|
263
261
|
end
|
@@ -294,6 +292,11 @@ Defect reports, feature requests, and pull requests are welcome on https://githu
|
|
294
292
|
None
|
295
293
|
|
296
294
|
|
295
|
+
### Development dependencies
|
296
|
+
|
297
|
+
None
|
298
|
+
|
299
|
+
|
297
300
|
### Dependents
|
298
301
|
|
299
302
|
**recls.Ruby** is used in the **[libCLImate.Ruby](https://github.com/synesissoftware/libCLImate.Ruby)** library.
|
@@ -14,22 +14,22 @@ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
|
14
14
|
require 'recls'
|
15
15
|
|
16
16
|
puts "files in current directory:"
|
17
|
-
Recls.
|
17
|
+
Recls.search(nil, nil, Recls::FILES).each { |fe| puts "\t#{fe.search_relative_path}" }
|
18
18
|
puts
|
19
19
|
|
20
20
|
puts "directories in current directory:"
|
21
|
-
Recls.
|
21
|
+
Recls.search(nil, nil, Recls::DIRECTORIES).each { |fe| puts "\t#{fe.search_relative_path}" }
|
22
22
|
puts
|
23
23
|
|
24
24
|
puts "files and directories in current directory:"
|
25
|
-
Recls.
|
25
|
+
Recls.search(nil, nil, Recls::DIRECTORIES | Recls::FILES).each { |fe| puts "\t#{fe.search_relative_path}" }
|
26
26
|
puts
|
27
27
|
```
|
28
28
|
|
29
29
|
## Discussion
|
30
30
|
|
31
31
|
The code is pretty self-explanatory, in that there are three searches using
|
32
|
-
the ```Recls.
|
32
|
+
the ```Recls.search()``` module method, passing FILES, DIRECTORIES, and
|
33
33
|
FILES|DIRECTORIES, respectively. For each search, a simple block is
|
34
34
|
presented, which takes a single-parameter of the file-entry (of type
|
35
35
|
``Recls::Entry``) from which the ``#search_relative_path`` instance
|
@@ -5,15 +5,15 @@ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
|
5
5
|
require 'recls'
|
6
6
|
|
7
7
|
puts "files in current directory:"
|
8
|
-
Recls.
|
8
|
+
Recls.search(nil, nil, Recls::FILES).each { |fe| puts "\t#{fe.search_relative_path}" }
|
9
9
|
puts
|
10
10
|
|
11
11
|
puts "directories in current directory:"
|
12
|
-
Recls.
|
12
|
+
Recls.search(nil, nil, Recls::DIRECTORIES).each { |fe| puts "\t#{fe.search_relative_path}" }
|
13
13
|
puts
|
14
14
|
|
15
15
|
puts "files and directories in current directory:"
|
16
|
-
Recls.
|
16
|
+
Recls.search(nil, nil, Recls::DIRECTORIES | Recls::FILES).each { |fe| puts "\t#{fe.search_relative_path}" }
|
17
17
|
puts
|
18
18
|
|
19
19
|
|
data/lib/recls/api.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Defines Recls module search functions
|
5
5
|
#
|
6
6
|
# Created: 9th June 2016
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -44,34 +44,44 @@ require 'recls/flags'
|
|
44
44
|
=begin
|
45
45
|
=end
|
46
46
|
|
47
|
-
# @!visibility private
|
48
|
-
class Object; end # :nodoc:
|
49
|
-
|
50
47
|
module Recls
|
51
48
|
|
52
|
-
#
|
49
|
+
# (*DEPRECATED*) Use {Recls.search}
|
53
50
|
def self.FileSearch(search_root, patterns, options = {})
|
54
51
|
|
55
|
-
|
52
|
+
self.search(search_root, patterns, options)
|
56
53
|
end
|
57
54
|
|
55
|
+
# (*DEPRECATED*) Use {Recls.rsearch}
|
56
|
+
def self.file_rsearch(search_root, patterns, options = {})
|
57
|
+
|
58
|
+
self.rsearch(search_root, patterns, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
# (*DEPRECATED*) Use {Recls.search}
|
62
|
+
def self.file_search(search_root, patterns, options = {})
|
63
|
+
|
64
|
+
self.search(search_root, patterns, options)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
58
68
|
# Initialises a +FileSearch+ instance, which acts recursively, as an
|
59
|
-
# +Enumerable+ of
|
69
|
+
# +Enumerable+ of {Recls::Entry}
|
60
70
|
#
|
61
71
|
# === Signature
|
62
72
|
#
|
63
73
|
# * *Parameters:*
|
64
|
-
# - +search_root+ (+String+,
|
65
|
-
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case
|
74
|
+
# - +search_root+ (+String+, {Recls::Entry}) The root directory of the search. May be +nil+, in which case the current directory is assumed;
|
75
|
+
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case {Recls::WILDCARDS_ALL} is assumed;
|
66
76
|
# - +options+ (+Hash+, +Integer+) Combination of flags (with behaviour as described below for the +flags+ option), or an options hash;
|
67
77
|
#
|
68
78
|
# * *Options:*
|
69
|
-
# - +flags+ (+Integer+) Combination of flags -
|
79
|
+
# - +flags+ (+Integer+) Combination of flags - {Recls::FILES}, {Recls::DIRECTORIES}, etc. If the value modulo {Recls::TYPEMASK} is 0, then {Recls::FILES} is assumed. The value {Recls::RECURSIVE} is added by the function, and so need not be added by the caller; it cannot be removed;
|
70
80
|
#
|
71
81
|
# === Return
|
72
82
|
# An instance of a class implementing +Enumerable+ whose value type is
|
73
|
-
#
|
74
|
-
def self.
|
83
|
+
# {Recls::Entry}.
|
84
|
+
def self.rsearch(search_root, patterns, options = {})
|
75
85
|
|
76
86
|
case options
|
77
87
|
when ::NilClass
|
@@ -95,22 +105,22 @@ module Recls
|
|
95
105
|
end
|
96
106
|
|
97
107
|
# Initialises a +FileSearch+ instance, which acts as an +Enumerable+
|
98
|
-
# of
|
108
|
+
# of {Recls::Entry}
|
99
109
|
#
|
100
110
|
# === Signature
|
101
111
|
#
|
102
112
|
# * *Parameters:*
|
103
|
-
# - +search_root+ (+String+,
|
104
|
-
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case
|
113
|
+
# - +search_root+ (+String+, {Recls::Entry}) The root directory of the search. May be +nil+, in which case the current directory is assumed;
|
114
|
+
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case {Recls::WILDCARDS_ALL} is assumed;
|
105
115
|
# - +options+ (+Hash+, +Integer+) Combination of flags (with behaviour as described below for the +flags+ option), or an options hash;
|
106
116
|
#
|
107
117
|
# * *Options:*
|
108
|
-
# - +flags+ (+Integer+) Combination of flags -
|
118
|
+
# - +flags+ (+Integer+) Combination of flags - {Recls::FILES}, {Recls::DIRECTORIES}, {Recls::RECURSIVE}, etc. If the value modulo {Recls::TYPEMASK} is 0, then {Recls::FILES} is assumed;
|
109
119
|
#
|
110
120
|
# === Return
|
111
121
|
# An instance of a class implementing +Enumerable+ whose value type is
|
112
|
-
#
|
113
|
-
def self.
|
122
|
+
# {Recls::Entry}.
|
123
|
+
def self.search(search_root, patterns, options = {})
|
114
124
|
|
115
125
|
Recls::FileSearch.new(search_root, patterns, options)
|
116
126
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Definition of Recls::compare_paths() for Ruby 1.x
|
5
5
|
#
|
6
6
|
# Created: 17th February 2014
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -43,9 +43,6 @@ require 'recls/ximpl/util'
|
|
43
43
|
=begin
|
44
44
|
=end
|
45
45
|
|
46
|
-
# @!visibility private
|
47
|
-
class Object; end # :nodoc:
|
48
|
-
|
49
46
|
module Recls
|
50
47
|
|
51
48
|
# Combines paths
|
@@ -53,7 +50,7 @@ module Recls
|
|
53
50
|
# === Signature
|
54
51
|
#
|
55
52
|
# * *Parameters:*
|
56
|
-
# - +paths+ (+[ (String
|
53
|
+
# - +paths+ (+[+ (+String+, {Recls::Entry}) +]+) Array of 1 or more path elements to be combined;
|
57
54
|
#
|
58
55
|
# === Return
|
59
56
|
# (+String+) The combined path.
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Definition of Recls::compare_paths() for Ruby 2+
|
5
5
|
#
|
6
6
|
# Created: 17th February 2014
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -43,9 +43,6 @@ require 'recls/ximpl/util'
|
|
43
43
|
=begin
|
44
44
|
=end
|
45
45
|
|
46
|
-
# @!visibility private
|
47
|
-
class Object; end # :nodoc:
|
48
|
-
|
49
46
|
module Recls
|
50
47
|
|
51
48
|
# Combines paths, optionally canonicalising them
|
@@ -53,7 +50,7 @@ module Recls
|
|
53
50
|
# === Signature
|
54
51
|
#
|
55
52
|
# * *Parameters:*
|
56
|
-
# - +paths+ (+
|
53
|
+
# - +paths+ ( +String+, {Recls::Entry} ) Array of 1 or more path elements to be combined;
|
57
54
|
# - +options+ (+Hash+) Options that moderate the combination;
|
58
55
|
#
|
59
56
|
# * *Options:*
|
data/lib/recls/entry.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Defines the Recls::Entry class for the recls.Ruby library.
|
5
5
|
#
|
6
6
|
# Created: 24th July 2012
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -46,9 +46,6 @@ require 'recls/flags'
|
|
46
46
|
=begin
|
47
47
|
=end
|
48
48
|
|
49
|
-
# @!visibility private
|
50
|
-
class Object; end # :nodoc:
|
51
|
-
|
52
49
|
module Recls
|
53
50
|
|
54
51
|
# A file-system entry
|
@@ -113,26 +110,24 @@ module Recls
|
|
113
110
|
# ##########################
|
114
111
|
# Name-related attributes
|
115
112
|
|
116
|
-
# (+String+) A normalised form of
|
113
|
+
# (+String+) A normalised form of {.path} that can be used in comparisons
|
117
114
|
attr_reader :compare_path
|
118
|
-
|
119
115
|
# (+String+) The full-path of the instance
|
120
116
|
attr_reader :path
|
121
|
-
# (+String+) The (Windows) short-form of
|
117
|
+
# (+String+) The (Windows) short-form of {.path}, or +nil+ if not on Windows
|
122
118
|
attr_reader :short_path
|
123
119
|
# (+String+) The (Windows) drive. +nil+ if does not exist
|
124
120
|
attr_reader :drive
|
125
|
-
# (+String+) The full path of the entry's directory (taking into account the
|
126
|
-
# #drive if on Windows)
|
121
|
+
# (+String+) The full path of the entry's directory (taking into account the {.drive} if on Windows)
|
127
122
|
attr_reader :directory_path
|
128
123
|
alias_method :dirname, :directory_path
|
129
|
-
# (+String+) The entry's directory (excluding the
|
124
|
+
# (+String+) The entry's directory (excluding the {.drive} if on Windows)
|
130
125
|
attr_reader :directory
|
131
|
-
# (+[ String ]+) An array of directory parts, where each part ends in Recls::PATH_NAME_SEPARATOR
|
126
|
+
# ( +[+ +String+ +]+ ) An array of directory parts, where each part ends in {Recls::PATH_NAME_SEPARATOR}
|
132
127
|
attr_reader :directory_parts
|
133
|
-
# (+String+) The entry's file name (combination of
|
128
|
+
# (+String+) The entry's file name (combination of {.stem} + {.extension})
|
134
129
|
attr_reader :file_full_name
|
135
|
-
# (+String+) The (Windows) short-form of
|
130
|
+
# (+String+) The (Windows) short-form of {.basename}, or +nil+ if not on Windows
|
136
131
|
attr_reader :file_short_name
|
137
132
|
alias_method :basename, :file_full_name
|
138
133
|
# (+String+) The entry's file stem
|
@@ -143,13 +138,13 @@ module Recls
|
|
143
138
|
alias_method :extension, :file_extension
|
144
139
|
# (+String+) The search directory if specified; +nil+ otherwise
|
145
140
|
attr_reader :search_directory
|
146
|
-
# (+String+) The
|
141
|
+
# (+String+) The +#path+ relative to {.search_directory}; +nil+ if no search directory specified
|
147
142
|
attr_reader :search_relative_path
|
148
|
-
# (+String+) The
|
143
|
+
# (+String+) The +#directory+ relative to {.search_directory}; +nil+ if no search directory specified
|
149
144
|
attr_reader :search_relative_directory
|
150
|
-
# (+String+) The
|
145
|
+
# (+String+) The +#directory_path+ relative to {.search_directory}; +nil+ if no search directory specified
|
151
146
|
attr_reader :search_relative_directory_path
|
152
|
-
# (+[ String ]+) The
|
147
|
+
# ( +[+ +String+ +]+ ) The +#directory_parts+ relative to {.search_directory}; +nil+ if no search directory specified
|
153
148
|
attr_reader :search_relative_directory_parts
|
154
149
|
|
155
150
|
# ##########################
|
@@ -182,7 +177,7 @@ module Recls
|
|
182
177
|
|
183
178
|
if Recls::Ximpl::OS::OS_IS_WINDOWS
|
184
179
|
|
185
|
-
#
|
180
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *system* bit
|
186
181
|
def system?
|
187
182
|
|
188
183
|
return false if @file_stat.nil?
|
@@ -190,7 +185,7 @@ module Recls
|
|
190
185
|
@file_stat.system?
|
191
186
|
end
|
192
187
|
|
193
|
-
#
|
188
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *archive* bit
|
194
189
|
def archive?
|
195
190
|
|
196
191
|
return false if @file_stat.nil?
|
@@ -198,7 +193,7 @@ module Recls
|
|
198
193
|
@file_stat.archive?
|
199
194
|
end
|
200
195
|
|
201
|
-
#
|
196
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry is a device
|
202
197
|
def device?
|
203
198
|
|
204
199
|
return false if @file_stat.nil?
|
@@ -206,7 +201,7 @@ module Recls
|
|
206
201
|
@file_stat.device?
|
207
202
|
end
|
208
203
|
|
209
|
-
#
|
204
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry is *normal*
|
210
205
|
def normal?
|
211
206
|
|
212
207
|
return false if @file_stat.nil?
|
@@ -214,7 +209,7 @@ module Recls
|
|
214
209
|
@file_stat.normal?
|
215
210
|
end
|
216
211
|
|
217
|
-
#
|
212
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *temporary* bit
|
218
213
|
def temporary?
|
219
214
|
|
220
215
|
return false if @file_stat.nil?
|
@@ -222,7 +217,7 @@ module Recls
|
|
222
217
|
@file_stat.temporary?
|
223
218
|
end
|
224
219
|
|
225
|
-
#
|
220
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *compressed* bit
|
226
221
|
def compressed?
|
227
222
|
|
228
223
|
return false if @file_stat.nil?
|
@@ -230,7 +225,7 @@ module Recls
|
|
230
225
|
@file_stat.compressed?
|
231
226
|
end
|
232
227
|
|
233
|
-
#
|
228
|
+
# (*WINDOWS-ONLY*) Indicates whether the entry has the *encrypted* bit
|
234
229
|
def encrypted?
|
235
230
|
|
236
231
|
return false if @file_stat.nil?
|
@@ -289,8 +284,7 @@ module Recls
|
|
289
284
|
|
290
285
|
# indicates the device of the given entry
|
291
286
|
#
|
292
|
-
# On Windows, this will be 0 if the entry cannot be
|
293
|
-
# opened
|
287
|
+
# On Windows, this will be 0 if the entry cannot be opened
|
294
288
|
def dev
|
295
289
|
|
296
290
|
@dev
|
@@ -298,8 +292,7 @@ module Recls
|
|
298
292
|
|
299
293
|
# indicates the ino of the given entry
|
300
294
|
#
|
301
|
-
# On Windows, this will be 0 if the entry cannot be
|
302
|
-
# opened
|
295
|
+
# On Windows, this will be 0 if the entry cannot be opened
|
303
296
|
def ino
|
304
297
|
|
305
298
|
@ino
|
@@ -307,8 +300,7 @@ module Recls
|
|
307
300
|
|
308
301
|
# number of links to the given entry
|
309
302
|
#
|
310
|
-
# On Windows, this will be 0 if the entry cannot be
|
311
|
-
# opened
|
303
|
+
# On Windows, this will be 0 if the entry cannot be opened
|
312
304
|
def nlink
|
313
305
|
|
314
306
|
@nlink
|
@@ -336,8 +328,8 @@ module Recls
|
|
336
328
|
# ##########################
|
337
329
|
# Comparison
|
338
330
|
|
339
|
-
# determines whether rhs is an instance of Entry and
|
340
|
-
#
|
331
|
+
# determines whether rhs is an instance of {Recls::Entry} and refers to
|
332
|
+
# the same path
|
341
333
|
def eql?(rhs)
|
342
334
|
|
343
335
|
case rhs
|
@@ -381,15 +373,13 @@ module Recls
|
|
381
373
|
# ##########################
|
382
374
|
# Conversion
|
383
375
|
|
384
|
-
# represents the entry as a string (in the form of
|
385
|
-
# the full path)
|
376
|
+
# represents the entry as a string (in the form of the full path)
|
386
377
|
def to_s
|
387
378
|
|
388
379
|
path
|
389
380
|
end
|
390
381
|
|
391
|
-
# represents the entry as a string (in the form of
|
392
|
-
# the full path)
|
382
|
+
# represents the entry as a string (in the form of the full path)
|
393
383
|
def to_str
|
394
384
|
|
395
385
|
path
|
data/lib/recls/file_search.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Defines the Recls::FileSearch class for the recls.Ruby library.
|
5
5
|
#
|
6
6
|
# Created: 24th July 2012
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -45,27 +45,25 @@ require 'recls/ximpl/os'
|
|
45
45
|
=begin
|
46
46
|
=end
|
47
47
|
|
48
|
-
# @!visibility private
|
49
|
-
class Object; end # :nodoc:
|
50
|
-
|
51
48
|
module Recls
|
52
49
|
|
50
|
+
# @!visibility private
|
53
51
|
class FileSearch # :nodoc: all
|
54
52
|
|
55
53
|
include Enumerable
|
56
54
|
|
57
55
|
# Initialises a +FileSearch+ instance, which acts as an +Enumerable+
|
58
|
-
# of
|
56
|
+
# of {Recls::Entry}
|
59
57
|
#
|
60
58
|
# === Signature
|
61
59
|
#
|
62
60
|
# * *Parameters:*
|
63
|
-
# - +search_root+ (+String+,
|
64
|
-
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case
|
61
|
+
# - +search_root+ (+String+, {Recls::Entry}) The root directory of the search. May be +nil+, in which case the current directory is assumed;
|
62
|
+
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case {Recls::WILDCARDS_ALL} is assumed;
|
65
63
|
# - +options+ (+Hash+, +Integer+) Combination of flags (with behaviour as described below for the +flags+ option), or an options hash;
|
66
64
|
#
|
67
65
|
# * *Options:*
|
68
|
-
# - +flags+ (+Integer+) Combination of flags -
|
66
|
+
# - +flags+ (+Integer+) Combination of flags - {Recls::FILES}, {Recls::DIRECTORIES}, {Recls::RECURSIVE}, etc. If the value modulo {Recls::TYPEMASK} is 0, then {Recls::FILES} is assumed;
|
69
67
|
#
|
70
68
|
# === Return
|
71
69
|
# An instance of the class.
|
@@ -140,7 +138,7 @@ module Recls
|
|
140
138
|
attr_reader :flags
|
141
139
|
|
142
140
|
# Calls the block once for each found file, passing a single
|
143
|
-
# parameter that is a Recls::Entry instance
|
141
|
+
# parameter that is a {Recls::Entry} instance
|
144
142
|
#
|
145
143
|
# @!visibility private
|
146
144
|
def each(&blk) # :nodoc:
|
data/lib/recls/flags.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Defines the Recls::Flags module for the recls.Ruby library.
|
5
5
|
#
|
6
6
|
# Created: 24th July 2012
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -40,9 +40,6 @@
|
|
40
40
|
=begin
|
41
41
|
=end
|
42
42
|
|
43
|
-
# @!visibility private
|
44
|
-
class Object; end # :nodoc:
|
45
|
-
|
46
43
|
module Recls
|
47
44
|
|
48
45
|
# Specifies that files are to be listed
|
@@ -53,21 +50,20 @@ module Recls
|
|
53
50
|
LINKS = 0x00000004
|
54
51
|
# Specifies that devices are to be listed
|
55
52
|
DEVICES = 0x00000008
|
56
|
-
# Type mask (combination of
|
53
|
+
# Type mask (combination of {Recls::FILES}, {Recls::DIRECTORIES}, {Recls::LINKS}, {Recls::DEVICES})
|
57
54
|
TYPEMASK = 0x000000ff
|
58
55
|
|
59
56
|
# Specifies that hidden items are to be shown and hidden directories are
|
60
57
|
# to be searched
|
61
58
|
SHOW_HIDDEN = 0x00000100
|
62
59
|
|
63
|
-
#
|
60
|
+
# (*IGNORED*) This for compatibility with *recls* libraries written in other languages
|
64
61
|
DIR_PROGRESS = 0x00001000
|
65
|
-
# Causes search to terminate if a directory cannot be entered or an
|
66
|
-
# entry's information cannot be +stat()+'d
|
62
|
+
# Causes search to terminate if a directory cannot be entered or an entry's file-system information cannot be obtained from the operating system
|
67
63
|
STOP_ON_ACCESS_FAILURE = 0x00002000
|
68
|
-
#
|
64
|
+
# (*IGNORED*) This for compatibility with *recls* libraries written in other languages
|
69
65
|
LINK_COUNT = 0000004000
|
70
|
-
#
|
66
|
+
# (*IGNORED*) This for compatibility with *recls* libraries written in other languages
|
71
67
|
NODE_INDEX = 0x00008000
|
72
68
|
|
73
69
|
# Causes search to operate recursively
|
@@ -76,13 +72,13 @@ private
|
|
76
72
|
# @!visibility private
|
77
73
|
NO_SEARCH_LINKS = 0x00020000 # :nodoc:
|
78
74
|
public
|
79
|
-
#
|
75
|
+
# (*IGNORED*) In previous versions the {Recls::Entry.directory_parts} property was not obtained (for performance reasons) unless this flag was specified. In current version the parts are always obtained
|
80
76
|
DIRECTORY_PARTS = 0x00040000
|
81
|
-
# Causes operations (such as
|
77
|
+
# Causes operations (such as {Recls.stat}) to obtain a result even when
|
82
78
|
# no corresponding file-system entity does not exist
|
83
79
|
DETAILS_LATER = 0x00080000
|
84
80
|
|
85
|
-
# Causes the
|
81
|
+
# Causes the {Recls::Entry.path} and {Recls::Entry.search_relative_path}
|
86
82
|
# attributes to contain a trailing path-name-separator for directory
|
87
83
|
# entries
|
88
84
|
MARK_DIRECTORIES = 0x00200000
|
data/lib/recls/foreach.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Definition of Recls::foreach() utility function
|
5
5
|
#
|
6
6
|
# Created: 22nd October 2014
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -43,9 +43,6 @@ require 'recls/file_search'
|
|
43
43
|
=begin
|
44
44
|
=end
|
45
45
|
|
46
|
-
# @!visibility private
|
47
|
-
class Object; end # :nodoc:
|
48
|
-
|
49
46
|
module Recls
|
50
47
|
|
51
48
|
private
|
@@ -87,22 +84,22 @@ module Recls
|
|
87
84
|
end # class FileSearchLineEnumerator
|
88
85
|
public
|
89
86
|
|
90
|
-
# Performs
|
91
|
-
# found
|
87
|
+
# Performs an optionally-recursive search and enumerates the lines of all
|
88
|
+
# files found
|
92
89
|
#
|
93
90
|
# === Signature
|
94
91
|
#
|
95
92
|
# * *Parameters:*
|
96
|
-
# - +searchable+ A searchable instance obtained from
|
97
|
-
# - +search_root+ (+String+,
|
98
|
-
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case
|
93
|
+
# - +searchable+ A searchable instance obtained from {Recls::search} or {Recls::rsearch};
|
94
|
+
# - +search_root+ (+String+, {Recls::Entry}) The root directory of the search. May be +nil+, in which case the current directory is assumed;
|
95
|
+
# - +patterns+ (+String+, +Array+) The pattern(s) for which to search. May be +nil+, in which case {Recls::WILDCARDS_ALL} is assumed;
|
99
96
|
# - +options+ (+Hash+) An options hash;
|
100
97
|
# - +flags+ (+Integer+) Combination of flags (with behaviour as described below for the +flags+ option);
|
101
98
|
#
|
102
99
|
# * *Block:*
|
103
100
|
# An optional block that will be executed once for each line in each file
|
104
101
|
# found, where the block must take 1, 2, or 3 parameters, representing the
|
105
|
-
# line [ +
|
102
|
+
# +line+ [, +file_line_index+ [, +entry+ ]]. If no block is given, an
|
106
103
|
# enumerator is returned.
|
107
104
|
#
|
108
105
|
# ==== Parameter Ordering
|
data/lib/recls/obsolete.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Obsolete elements
|
5
5
|
#
|
6
6
|
# Created: 19th July 2012
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -43,10 +43,7 @@
|
|
43
43
|
|
44
44
|
if not defined? RECLS_NO_OBSOLETE
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
# @!visibility private
|
49
|
-
module Recls # :nodoc: all
|
46
|
+
module Recls
|
50
47
|
|
51
48
|
# @!visibility private
|
52
49
|
def self.pathNameSeparator
|
@@ -116,8 +113,6 @@ if not defined? RECLS_NO_OBSOLETE
|
|
116
113
|
alias_method :creationTime, :modification_time
|
117
114
|
end
|
118
115
|
end # module Recls
|
119
|
-
|
120
|
-
# :startdoc:
|
121
116
|
end
|
122
117
|
|
123
118
|
|
data/lib/recls/recls.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Main source file for recls library
|
5
5
|
#
|
6
6
|
# Created: 19th July 2012
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -37,21 +37,22 @@
|
|
37
37
|
# ######################################################################## #
|
38
38
|
|
39
39
|
|
40
|
-
# The *recls* module
|
40
|
+
# The main *recls* module
|
41
41
|
#
|
42
|
-
#
|
43
|
-
# - Recls::Entry
|
44
|
-
# - Recls
|
45
|
-
# - Recls
|
46
|
-
# - Recls
|
47
|
-
# - Recls
|
48
|
-
# - Recls
|
49
|
-
# - Recls::
|
50
|
-
# - Recls::
|
51
|
-
# - Recls::
|
52
|
-
# - Recls
|
53
|
-
# - Recls
|
54
|
-
# - Recls
|
42
|
+
# === Significant Components
|
43
|
+
# - {Recls::Entry} - a file-system entry
|
44
|
+
# - {Recls.absolute_path} - converts a path to absolute;
|
45
|
+
# - {Recls.absolute_path?} - determines whether a path is absolute;
|
46
|
+
# - {Recls.canonicalise_path} - canonicalises a path;
|
47
|
+
# - {Recls.combine_paths} - combines a number of path elements;
|
48
|
+
# - {Recls.derive_relative_path} - derives a relative path, with respect to a given origin;
|
49
|
+
# - {Recls.directory?} - obtains an {Recls::Entry} for the path if it exists and is a directory, or +nil+ otherwise;
|
50
|
+
# - {Recls.exist?} - obtains an {Recls::Entry} for the path if it exists, or +nil+ otherwise;
|
51
|
+
# - {Recls.file?} - obtains an {Recls::Entry} for the path if it exists and is a file, or +nil+ otherwise;
|
52
|
+
# - {Recls.foreach} - performs an optionally-recursive search and enumerates the lines of all files found
|
53
|
+
# - {Recls.rsearch} - conducts a recursive search under a given search-directory for entries matching given pattern(s);
|
54
|
+
# - {Recls.search} - conducts a non-recursive search under a given search-directory for entries matching given pattern(s);
|
55
|
+
# - {Recls.stat} - attempts to obtain an {Recls::Entry} for the given path, or +nil+ if it fails to do so;
|
55
56
|
module Recls
|
56
57
|
end # module Recls
|
57
58
|
|
data/lib/recls/stat.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Defines the Recls.stat() method for the recls.Ruby library.
|
5
5
|
#
|
6
6
|
# Created: 24th July 2012
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -44,25 +44,22 @@ require 'recls/flags'
|
|
44
44
|
=begin
|
45
45
|
=end
|
46
46
|
|
47
|
-
# @!visibility private
|
48
|
-
class Object; end # :nodoc:
|
49
|
-
|
50
47
|
module Recls
|
51
48
|
|
52
|
-
# Equivalent to
|
49
|
+
# Equivalent to {Recls.stat} but only returns (a non-+nil+ value) if the
|
53
50
|
# path exists _and_ represents a directory
|
54
51
|
#
|
55
52
|
# This has two advantages over +File.directory?+: it obtains a
|
56
|
-
# Recls::Entry in the case where the path represents a directory; and
|
57
|
-
# it does '~' interpretation
|
53
|
+
# {Recls::Entry} in the case where the path represents a directory; and
|
54
|
+
# it does +'~'+ interpretation
|
58
55
|
#
|
59
56
|
# === Signature
|
60
57
|
#
|
61
58
|
# * *Parameters:*
|
62
|
-
# - +path+ (+String+,
|
59
|
+
# - +path+ (+String+, {Recls::Entry}) The path;
|
63
60
|
#
|
64
61
|
# === Return
|
65
|
-
# (
|
62
|
+
# ({Recls::Entry}, +nil+) The entry if +path+ exists and is a directory; +nil+ otherwise.
|
66
63
|
def self.directory?(path, *args)
|
67
64
|
|
68
65
|
fe = self.stat(path, *args)
|
@@ -75,20 +72,20 @@ module Recls
|
|
75
72
|
fe
|
76
73
|
end
|
77
74
|
|
78
|
-
# Equivalent to
|
75
|
+
# Equivalent to {Recls.stat} but only returns (a non-+nil+ value) if the
|
79
76
|
# path exists _and_ represents a file
|
80
77
|
#
|
81
78
|
# This has two advantages over +File.file?+: it obtains a
|
82
|
-
# Recls::Entry in the case where the path represents a file; and
|
83
|
-
# it does '~' interpretation
|
79
|
+
# {Recls::Entry} in the case where the path represents a file; and
|
80
|
+
# it does +'~'+ interpretation
|
84
81
|
#
|
85
82
|
# === Signature
|
86
83
|
#
|
87
84
|
# * *Parameters:*
|
88
|
-
# - +path+ (+String+,
|
85
|
+
# - +path+ (+String+, {Recls::Entry}) The path;
|
89
86
|
#
|
90
87
|
# === Return
|
91
|
-
# (
|
88
|
+
# ({Recls::Entry}, +nil+) The entry if +path+ exists and is a file; +nil+ otherwise.
|
92
89
|
def self.file?(path, *args)
|
93
90
|
|
94
91
|
fe = self.stat(path, *args)
|
@@ -101,7 +98,7 @@ module Recls
|
|
101
98
|
fe
|
102
99
|
end
|
103
100
|
|
104
|
-
# Obtains a single Recls::Entry instance from a path, according to the
|
101
|
+
# Obtains a single {Recls::Entry} instance from a path, according to the
|
105
102
|
# given arguments, which can be any combination of search-root and
|
106
103
|
# flags, as discussed below
|
107
104
|
#
|
@@ -109,8 +106,8 @@ module Recls
|
|
109
106
|
#
|
110
107
|
# * *Parameters:*
|
111
108
|
# - +path+ (+String+) A path to evaluate. May not be +nil+;
|
112
|
-
# - +search_root+ (+String+,
|
113
|
-
# - +flags+ (+Integer+) A bit-combined set of flags (such as
|
109
|
+
# - +search_root+ (+String+, {Recls::Entry}) A directory from which the returned +Entry+ instance's search-relative attributes are evaluated;
|
110
|
+
# - +flags+ (+Integer+) A bit-combined set of flags (such as {Recls::DIRECTORIES}, {Recls::FILES}, {Recls::RECURSIVE}, {Recls::DETAILS_LATER}, and so on);
|
114
111
|
#
|
115
112
|
# ==== Parameter Ordering
|
116
113
|
#
|
@@ -122,9 +119,9 @@ module Recls
|
|
122
119
|
# - +path+, +search_root+, +flags+
|
123
120
|
#
|
124
121
|
# === Return
|
125
|
-
# (
|
122
|
+
# ({Recls::Entry}) An entry representing the path on the file-system, or
|
126
123
|
# +nil+ if the path does not refer to an existing entity. If the
|
127
|
-
#
|
124
|
+
# {Recls::DETAILS_LATER} flag is included, then an entry is returned
|
128
125
|
# regardless of its existence.
|
129
126
|
def self.stat(path, *args)
|
130
127
|
|
data/lib/recls/util.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Utility module functions for recls library
|
5
5
|
#
|
6
6
|
# Created: 17th February 2014
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -45,9 +45,6 @@ require 'recls/ximpl/os'
|
|
45
45
|
=begin
|
46
46
|
=end
|
47
47
|
|
48
|
-
# @!visibility private
|
49
|
-
class Object; end # :nodoc:
|
50
|
-
|
51
48
|
module Recls
|
52
49
|
|
53
50
|
# Obtains the absolute form of the given path
|
@@ -55,7 +52,7 @@ module Recls
|
|
55
52
|
# === Signature
|
56
53
|
#
|
57
54
|
# * *Parameters:*
|
58
|
-
# - +path+ (+String+,
|
55
|
+
# - +path+ (+String+, {Recls::Entry}) The path;
|
59
56
|
#
|
60
57
|
# === Return
|
61
58
|
# (+String+) The absolute form of the path.
|
@@ -64,13 +61,13 @@ module Recls
|
|
64
61
|
Recls::Ximpl.absolute_path path
|
65
62
|
end
|
66
63
|
|
67
|
-
# Canonicalises the given path, by removing dots
|
68
|
-
#
|
64
|
+
# Canonicalises the given path, by removing dots directories,
|
65
|
+
# i.e. +'.'+ and +'..'+
|
69
66
|
#
|
70
67
|
# === Signature
|
71
68
|
#
|
72
69
|
# * *Parameters:*
|
73
|
-
# - +path+ (+String+,
|
70
|
+
# - +path+ (+String+, {Recls::Entry}) The path;
|
74
71
|
#
|
75
72
|
# === Return
|
76
73
|
# (+String+) The canonical form of the path.
|
@@ -87,8 +84,8 @@ module Recls
|
|
87
84
|
# === Signature
|
88
85
|
#
|
89
86
|
# * *Parameters:*
|
90
|
-
# - +origin+ (+String+,
|
91
|
-
# - +path+ (+String+,
|
87
|
+
# - +origin+ (+String+, {Recls::Entry}) The path against which +path+ will be evaluated;
|
88
|
+
# - +path+ (+String+, {Recls::Entry}) The path to evaluate;
|
92
89
|
#
|
93
90
|
# === Return
|
94
91
|
# (+String+) The relative form of the path.
|
@@ -108,16 +105,16 @@ end
|
|
108
105
|
|
109
106
|
module Recls
|
110
107
|
|
111
|
-
# Indicates whether the given path exists, obtaining a Recls::Entry
|
108
|
+
# Indicates whether the given path exists, obtaining a {Recls::Entry}
|
112
109
|
# instance if so
|
113
110
|
#
|
114
111
|
# === Signature
|
115
112
|
#
|
116
113
|
# * *Parameters:*
|
117
|
-
# - +path+ (+String+,
|
114
|
+
# - +path+ (+String+, {Recls::Entry}) The path;
|
118
115
|
#
|
119
116
|
# === Return
|
120
|
-
# (
|
117
|
+
# ({Recls::Entry}, +nil+) The entry if +path+ exists; +nil+ otherwise.
|
121
118
|
def self.exist?(path)
|
122
119
|
|
123
120
|
return nil if path.nil?
|
@@ -130,7 +127,7 @@ module Recls
|
|
130
127
|
# === Signature
|
131
128
|
#
|
132
129
|
# * *Parameters:*
|
133
|
-
# - +path+ (+String+,
|
130
|
+
# - +path+ (+String+, {Recls::Entry}, +nil+) The path to be evaluated;
|
134
131
|
#
|
135
132
|
# === Return
|
136
133
|
# (boolean) +true+ if +path+ is absolute; +false+ otherwise.
|
data/lib/recls/version.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Version for recls library
|
5
5
|
#
|
6
6
|
# Created: 14th February 2014
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -40,13 +40,10 @@
|
|
40
40
|
=begin
|
41
41
|
=end
|
42
42
|
|
43
|
-
# @!visibility private
|
44
|
-
class Object; end # :nodoc:
|
45
|
-
|
46
43
|
module Recls
|
47
44
|
|
48
45
|
# Current version of the recls.Ruby library
|
49
|
-
VERSION = '2.13.0'
|
46
|
+
VERSION = '2.13.0.1'
|
50
47
|
|
51
48
|
private
|
52
49
|
# @!visibility private
|
data/lib/recls/ximpl/os.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# recls library.
|
6
6
|
#
|
7
7
|
# Created: 16th February 2014
|
8
|
-
# Updated:
|
8
|
+
# Updated: 21st April 2024
|
9
9
|
#
|
10
10
|
# Author: Matthew Wilson
|
11
11
|
#
|
@@ -41,14 +41,12 @@
|
|
41
41
|
=begin
|
42
42
|
=end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
# @!visibility private
|
47
|
-
module Recls # :nodoc:
|
44
|
+
module Recls
|
48
45
|
|
49
46
|
# @!visibility private
|
50
47
|
module Ximpl # :nodoc: all
|
51
48
|
|
49
|
+
# @!visibility private
|
52
50
|
module OS # :nodoc: all
|
53
51
|
|
54
52
|
# @!visibility private
|
@@ -95,7 +93,6 @@ module Recls # :nodoc:
|
|
95
93
|
end # module Ximpl
|
96
94
|
end # module Recls
|
97
95
|
|
98
|
-
# :startdoc:
|
99
96
|
|
100
97
|
# ############################## end of file ############################# #
|
101
98
|
|
data/lib/recls/ximpl/unix.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: UNIX-specific constructs for the recls library.
|
5
5
|
#
|
6
6
|
# Created: 19th February 2014
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -43,9 +43,7 @@ require 'recls/ximpl/util'
|
|
43
43
|
=begin
|
44
44
|
=end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
module Recls # :nodoc:
|
46
|
+
module Recls
|
49
47
|
|
50
48
|
# @!visibility private
|
51
49
|
module Ximpl # :nodoc: all
|
@@ -54,8 +52,7 @@ module Recls # :nodoc:
|
|
54
52
|
class FileStat < File::Stat # :nodoc:
|
55
53
|
|
56
54
|
private
|
57
|
-
|
58
|
-
def initialize(path) # :nodoc:
|
55
|
+
def initialize(path)
|
59
56
|
|
60
57
|
@path = path
|
61
58
|
|
@@ -63,11 +60,9 @@ module Recls # :nodoc:
|
|
63
60
|
end
|
64
61
|
|
65
62
|
public
|
66
|
-
|
67
|
-
attr_reader :path # :nodoc:
|
63
|
+
attr_reader :path
|
68
64
|
|
69
|
-
|
70
|
-
def hidden? # :nodoc:
|
65
|
+
def hidden?
|
71
66
|
|
72
67
|
basename = File.basename @path
|
73
68
|
|
@@ -80,18 +75,14 @@ module Recls # :nodoc:
|
|
80
75
|
end
|
81
76
|
|
82
77
|
public
|
83
|
-
|
84
|
-
def FileStat.stat(path) # :nodoc:
|
78
|
+
def FileStat.stat(path)
|
85
79
|
|
86
80
|
Recls::Ximpl::FileStat.new(path)
|
87
|
-
|
88
81
|
end
|
89
82
|
end # class FileStat
|
90
83
|
end # module Ximpl
|
91
84
|
end # module Recls
|
92
85
|
|
93
|
-
# :startdoc:
|
94
|
-
|
95
86
|
|
96
87
|
# ############################## end of file ############################# #
|
97
88
|
|
data/lib/recls/ximpl/util.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Internal implementation constructs for the recls library.
|
5
5
|
#
|
6
6
|
# Created: 24th July 2012
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -46,13 +46,12 @@ require 'pathname'
|
|
46
46
|
=begin
|
47
47
|
=end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
module Recls # :nodoc:
|
49
|
+
module Recls
|
52
50
|
|
53
51
|
# @!visibility private
|
54
52
|
module Ximpl # :nodoc: all
|
55
53
|
|
54
|
+
# @!visibility private
|
56
55
|
module Util # :nodoc: all
|
57
56
|
|
58
57
|
# @!visibility private
|
@@ -832,8 +831,7 @@ module Recls # :nodoc:
|
|
832
831
|
#
|
833
832
|
# Some known conditions:
|
834
833
|
#
|
835
|
-
# * (Mac OSX) /dev/fd/<N> - some of these stat() as directories but
|
836
|
-
# Dir.new fails with ENOTDIR
|
834
|
+
# * (Mac OSX) /dev/fd/<N> - some of these +stat()+ as directories but +Dir.new+ fails with +ENOTDIR+;
|
837
835
|
#
|
838
836
|
# @!visibility private
|
839
837
|
def self.dir_entries_maybe(dir, flags) # :nodoc:
|
@@ -877,8 +875,6 @@ module Recls # :nodoc:
|
|
877
875
|
end # module Ximpl
|
878
876
|
end # module Recls
|
879
877
|
|
880
|
-
# :startdoc:
|
881
|
-
|
882
878
|
|
883
879
|
# ############################## end of file ############################# #
|
884
880
|
|
data/lib/recls/ximpl/windows.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Purpose: Windows-specific constructs for the recls library.
|
5
5
|
#
|
6
6
|
# Created: 19th February 2014
|
7
|
-
# Updated:
|
7
|
+
# Updated: 21st April 2024
|
8
8
|
#
|
9
9
|
# Author: Matthew Wilson
|
10
10
|
#
|
@@ -43,9 +43,7 @@ require 'Win32API'
|
|
43
43
|
=begin
|
44
44
|
=end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
module Recls # :nodoc:
|
46
|
+
module Recls
|
49
47
|
|
50
48
|
# @!visibility private
|
51
49
|
module Ximpl # :nodoc: all
|
@@ -225,8 +223,6 @@ module Recls # :nodoc:
|
|
225
223
|
end # module Ximpl
|
226
224
|
end # module Recls
|
227
225
|
|
228
|
-
# :startdoc:
|
229
|
-
|
230
226
|
|
231
227
|
# ############################## end of file ############################# #
|
232
228
|
|
@@ -17,7 +17,6 @@ Recls.foreach(Recls::FileSearch.new(nil, '*.rb', Recls::RECURSIVE)).each do |lin
|
|
17
17
|
puts "#{fe.search_relative_path}(#{line_number + 1}): #{line}"
|
18
18
|
|
19
19
|
count_1 += 1
|
20
|
-
break if 20 == count_1
|
21
20
|
end
|
22
21
|
|
23
22
|
puts
|
@@ -32,7 +31,6 @@ e.each do |line, line_number, fe|
|
|
32
31
|
puts "#{fe.search_relative_path}(#{line_number + 1}): #{line}"
|
33
32
|
|
34
33
|
count_2 += 1
|
35
|
-
break if 20 == count_2
|
36
34
|
end
|
37
35
|
|
38
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recls-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.13.0
|
4
|
+
version: 2.13.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xqsr3
|