recls-ruby 2.13.1 → 2.13.4
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/AUTHORS.md +21 -0
- data/CHANGES.md +216 -0
- data/CONTRIBUTING.md +36 -0
- data/EXAMPLES.md +11 -0
- data/FAQ.md +28 -0
- data/INSTALL.md +41 -0
- data/LICENSE +3 -5
- data/NEWS.md +42 -0
- data/README.md +79 -35
- data/Rakefile +21 -1
- data/SECURITY.md +23 -0
- data/TODO.md +24 -0
- data/examples/find_files_and_directories.md +3 -2
- data/examples/find_files_and_directories.recursive.md +3 -2
- data/examples/show_hidden_files.md +9 -4
- data/examples/show_readonly_files.md +8 -4
- data/lib/recls/api.rb +2 -1
- data/lib/recls/combine_paths_1.rb +29 -4
- data/lib/recls/combine_paths_2plus.rb +29 -4
- data/lib/recls/entry.rb +18 -6
- data/lib/recls/file_search.rb +3 -2
- data/lib/recls/flags.rb +2 -1
- data/lib/recls/foreach.rb +2 -1
- data/lib/recls/obsolete.rb +2 -1
- data/lib/recls/recls.rb +2 -1
- data/lib/recls/stat.rb +2 -1
- data/lib/recls/util.rb +2 -1
- data/lib/recls/version.rb +4 -3
- data/lib/recls/ximpl/os.rb +2 -1
- data/lib/recls/ximpl/unix.rb +19 -4
- data/lib/recls/ximpl/util.rb +10 -4
- data/lib/recls/ximpl/windows.rb +29 -6
- data/lib/recls.rb +2 -1
- data/test/unit/tc_recls_util.rb +0 -109
- data/test/unit/util/tc_combine_paths.rb +157 -0
- data/test/unit/util/ts_all.rb +22 -0
- metadata +45 -17
data/TODO.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# recls.Ruby - TODO <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Functional improvements
|
|
5
|
+
|
|
6
|
+
* \<none>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Performance improvements
|
|
10
|
+
|
|
11
|
+
* \<none>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Packaging improvements
|
|
15
|
+
|
|
16
|
+
* [x] ~~~complete **.github/workflows/ruby.yml** (matrix, gem smoke, warnings job) to match **xqsr3**~~~;
|
|
17
|
+
* [x] ~~~implement **Rakefile** `test` / `default` tasks for `bundle exec rake test`~~~;
|
|
18
|
+
* [x] ~~~fix **recls.gemspec** metadata URIs and homepage to **recls.Ruby** (HTTPS)~~~;
|
|
19
|
+
* [x] ~~~rename gemspec so the filename stem matches `spec.name` (`recls.gemspec` → **recls-ruby.gemspec**)~~~;
|
|
20
|
+
* [x] ~~~obtain a **run_all_unit_tests.sh** (from **misc-dev-scripts**) that skips `tput` when `$TERM` is unset or stdout is not a TTY (CI: `tput: No value for $TERM and no -T specified`)~~~;
|
|
21
|
+
* [x] ~~~after this packaging/boilerplate/CI lift: bump **VERSION** to **2.13.4** and align the gem~~~;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<!-- ########################### end of file ########################### -->
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
# recls.Ruby Example - **find_files_and_directories**
|
|
1
|
+
# recls.Ruby - Example - **find_files_and_directories**
|
|
2
2
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
5
|
-
Illustrates finding of FILES, then DIRECTORIES, then both
|
|
5
|
+
Illustrates non-recursive finding of FILES, then DIRECTORIES, then both.
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
## Source
|
|
8
9
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
# recls.Ruby Example - **find_files_and_directories.recursive**
|
|
1
|
+
# recls.Ruby - Example - **find_files_and_directories.recursive**
|
|
2
2
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
5
|
-
Illustrates recursive finding of FILES, then DIRECTORIES, then both
|
|
5
|
+
Illustrates recursive finding of FILES, then DIRECTORIES, then both.
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
## Source
|
|
8
9
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
# recls.Ruby Example - **show_hidden_files**
|
|
1
|
+
# recls.Ruby - Example - **show_hidden_files**
|
|
2
2
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Illustrates recursive searching for hidden files via `Recls::SHOW_HIDDEN` and filtering with `Recls::Entry#hidden?`.
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
## Source
|
|
8
9
|
|
|
@@ -23,9 +24,14 @@ Recls.file_rsearch('.', Recls::WILDCARDS_ALL, Recls::FILES | Recls::SHOW_HIDDEN)
|
|
|
23
24
|
end
|
|
24
25
|
```
|
|
25
26
|
|
|
27
|
+
|
|
26
28
|
## Discussion
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
By default, searches omit hidden entries. Including `Recls::SHOW_HIDDEN` causes
|
|
31
|
+
them to be returned; the example then keeps only those for which `#hidden?` is
|
|
32
|
+
true. (The older `Recls.file_rsearch` name is retained for compatibility;
|
|
33
|
+
`Recls.rsearch` is preferred.)
|
|
34
|
+
|
|
29
35
|
|
|
30
36
|
## Example results
|
|
31
37
|
|
|
@@ -39,4 +45,3 @@ TBC
|
|
|
39
45
|
|
|
40
46
|
|
|
41
47
|
<!-- ########################### end of file ########################### -->
|
|
42
|
-
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
# recls.Ruby Example - **show_hidden_files**
|
|
1
|
+
# recls.Ruby - Example - **show_hidden_files**
|
|
2
2
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Illustrates recursive searching for read-only files by filtering with `Recls::Entry#readonly?`.
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
## Source
|
|
8
9
|
|
|
@@ -22,9 +23,13 @@ Recls.file_rsearch('.', Recls::WILDCARDS_ALL, Recls::FILES).each do |fe|
|
|
|
22
23
|
end
|
|
23
24
|
```
|
|
24
25
|
|
|
26
|
+
|
|
25
27
|
## Discussion
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
Unlike hidden entries, read-only files are returned by a normal files search;
|
|
30
|
+
filtering is done solely via `#readonly?`. (The older `Recls.file_rsearch` name
|
|
31
|
+
is retained for compatibility; `Recls.rsearch` is preferred.)
|
|
32
|
+
|
|
28
33
|
|
|
29
34
|
## Example results
|
|
30
35
|
|
|
@@ -35,4 +40,3 @@ TBC
|
|
|
35
40
|
|
|
36
41
|
|
|
37
42
|
<!-- ########################### end of file ########################### -->
|
|
38
|
-
|
data/lib/recls/api.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/api.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Defines Recls module search functions
|
|
5
6
|
#
|
|
6
7
|
# Created: 9th June 2016
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/compare_paths_1.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Definition of Recls::compare_paths() for Ruby 1.x
|
|
5
6
|
#
|
|
6
7
|
# Created: 17th February 2014
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
12
|
+
# Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems
|
|
12
13
|
# Copyright (c) 2014-2019, Matthew Wilson and Synesis Software
|
|
13
14
|
# All rights reserved.
|
|
14
15
|
#
|
|
@@ -45,7 +46,16 @@ require 'recls/ximpl/util'
|
|
|
45
46
|
|
|
46
47
|
module Recls
|
|
47
48
|
|
|
48
|
-
# Combines paths
|
|
49
|
+
# Combines paths, optionally canonicalising them.
|
|
50
|
+
#
|
|
51
|
+
# Unlike `File::join()`, this method takes account of relative vs absolute
|
|
52
|
+
# elements in the sequence. Specifically, the rightmost non-relative
|
|
53
|
+
# element, if it exists, anchors the combination, such that any arguments
|
|
54
|
+
# to the left are ignored. Furthermore, any entries (of type
|
|
55
|
+
# `Recls::Entry`) in the sequence are given special treatment as follows:
|
|
56
|
+
# - a rightmost `#file?` or `#device?` is returned as the complete result;
|
|
57
|
+
# - a rightmost `#directory?` causes all prior elements to be ignored and
|
|
58
|
+
# may be combined with subsequent elements;
|
|
49
59
|
#
|
|
50
60
|
# === Signature
|
|
51
61
|
#
|
|
@@ -60,7 +70,22 @@ module Recls
|
|
|
60
70
|
|
|
61
71
|
raise ArgumentError, 'must specify one or more path elements' if paths.empty?
|
|
62
72
|
|
|
63
|
-
ix_last_entry = paths.rindex { |path| ::Recls::Entry === path }
|
|
73
|
+
ix_last_entry = paths.rindex { |path| ::Recls::Entry === path }
|
|
74
|
+
|
|
75
|
+
if ix_last_entry
|
|
76
|
+
|
|
77
|
+
fe = paths[ix_last_entry]
|
|
78
|
+
|
|
79
|
+
if fe.directory?
|
|
80
|
+
|
|
81
|
+
paths = paths[ix_last_entry..-1]
|
|
82
|
+
else
|
|
83
|
+
|
|
84
|
+
return fe
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
paths = paths.map { |path| path.to_str }
|
|
64
89
|
|
|
65
90
|
return Recls::Ximpl.combine_paths paths, {}
|
|
66
91
|
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/compare_paths_2plus.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Definition of Recls::compare_paths() for Ruby 2+
|
|
5
6
|
#
|
|
6
7
|
# Created: 17th February 2014
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
12
|
+
# Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems
|
|
12
13
|
# Copyright (c) 2014-2019, Matthew Wilson and Synesis Software
|
|
13
14
|
# All rights reserved.
|
|
14
15
|
#
|
|
@@ -45,7 +46,16 @@ require 'recls/ximpl/util'
|
|
|
45
46
|
|
|
46
47
|
module Recls
|
|
47
48
|
|
|
48
|
-
# Combines paths, optionally canonicalising them
|
|
49
|
+
# Combines paths, optionally canonicalising them.
|
|
50
|
+
#
|
|
51
|
+
# Unlike `File::join()`, this method takes account of relative vs absolute
|
|
52
|
+
# elements in the sequence. Specifically, the rightmost non-relative
|
|
53
|
+
# element, if it exists, anchors the combination, such that any arguments
|
|
54
|
+
# to the left are ignored. Furthermore, any entries (of type
|
|
55
|
+
# `Recls::Entry`) in the sequence are given special treatment as follows:
|
|
56
|
+
# - a rightmost `#file?` or `#device?` is returned as the complete result;
|
|
57
|
+
# - a rightmost `#directory?` causes all prior elements to be ignored and
|
|
58
|
+
# may be combined with subsequent elements;
|
|
49
59
|
#
|
|
50
60
|
# === Signature
|
|
51
61
|
#
|
|
@@ -66,7 +76,22 @@ module Recls
|
|
|
66
76
|
|
|
67
77
|
raise ArgumentError, 'must specify one or more path elements' if paths.empty?
|
|
68
78
|
|
|
69
|
-
ix_last_entry = paths.rindex { |path| ::Recls::Entry === path }
|
|
79
|
+
ix_last_entry = paths.rindex { |path| ::Recls::Entry === path }
|
|
80
|
+
|
|
81
|
+
if ix_last_entry
|
|
82
|
+
|
|
83
|
+
fe = paths[ix_last_entry]
|
|
84
|
+
|
|
85
|
+
if fe.directory?
|
|
86
|
+
|
|
87
|
+
paths = paths[ix_last_entry..-1]
|
|
88
|
+
else
|
|
89
|
+
|
|
90
|
+
return fe
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
paths = paths.map { |path| path.to_str }
|
|
70
95
|
|
|
71
96
|
return Recls::Ximpl.combine_paths paths, options
|
|
72
97
|
end
|
data/lib/recls/entry.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/entry.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Defines the Recls::Entry class for the recls.Ruby library.
|
|
5
6
|
#
|
|
6
7
|
# Created: 24th July 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
12
|
+
# Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems
|
|
12
13
|
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
|
13
14
|
# All rights reserved.
|
|
14
15
|
#
|
|
@@ -64,6 +65,7 @@ module Recls
|
|
|
64
65
|
def initialize(path, file_stat, search_dir, flags)
|
|
65
66
|
|
|
66
67
|
@file_stat = file_stat
|
|
68
|
+
@flags = flags
|
|
67
69
|
|
|
68
70
|
@path = Recls::Ximpl.absolute_path path
|
|
69
71
|
@short_path = nil
|
|
@@ -104,6 +106,8 @@ module Recls
|
|
|
104
106
|
@short_path = @file_stat.short_path
|
|
105
107
|
@file_short_name = Recls::Ximpl::Util.split_path(@short_path)[2]
|
|
106
108
|
else
|
|
109
|
+
|
|
110
|
+
;
|
|
107
111
|
end
|
|
108
112
|
end
|
|
109
113
|
|
|
@@ -237,9 +241,13 @@ module Recls
|
|
|
237
241
|
# indicates whether the given entry represents a directory
|
|
238
242
|
def directory?
|
|
239
243
|
|
|
240
|
-
|
|
244
|
+
if @file_stat.nil?
|
|
241
245
|
|
|
242
|
-
|
|
246
|
+
(Recls::DETAILS_LATER | Recls::DIRECTORIES) == ((Recls::DETAILS_LATER | Recls::DIRECTORIES) & @flags)
|
|
247
|
+
else
|
|
248
|
+
|
|
249
|
+
@file_stat.directory?
|
|
250
|
+
end
|
|
243
251
|
end
|
|
244
252
|
|
|
245
253
|
alias_method :dir?, :directory?
|
|
@@ -247,9 +255,13 @@ module Recls
|
|
|
247
255
|
# indicates whether the given entry represents a file
|
|
248
256
|
def file?
|
|
249
257
|
|
|
250
|
-
|
|
258
|
+
if @file_stat.nil?
|
|
259
|
+
|
|
260
|
+
(Recls::DETAILS_LATER | Recls::FILES) == ((Recls::DETAILS_LATER | Recls::FILES) & @flags)
|
|
261
|
+
else
|
|
251
262
|
|
|
252
|
-
|
|
263
|
+
@file_stat.file?
|
|
264
|
+
end
|
|
253
265
|
end
|
|
254
266
|
|
|
255
267
|
# indicates whether the given entry represents a link
|
data/lib/recls/file_search.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/file_search.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Defines the Recls::FileSearch class for the recls.Ruby library.
|
|
5
6
|
#
|
|
6
7
|
# Created: 24th July 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
@@ -203,7 +204,7 @@ module Recls
|
|
|
203
204
|
rescue Errno::ENOENT, Errno::ENXIO
|
|
204
205
|
|
|
205
206
|
nil
|
|
206
|
-
rescue SystemCallError
|
|
207
|
+
rescue SystemCallError
|
|
207
208
|
|
|
208
209
|
# TODO this should be filtered up and/or logged
|
|
209
210
|
|
data/lib/recls/flags.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/flags.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Defines the Recls::Flags module for the recls.Ruby library.
|
|
5
6
|
#
|
|
6
7
|
# Created: 24th July 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
data/lib/recls/foreach.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/foreach.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Definition of Recls::foreach() utility function
|
|
5
6
|
#
|
|
6
7
|
# Created: 22nd October 2014
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
data/lib/recls/obsolete.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/obsolete.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Obsolete elements
|
|
5
6
|
#
|
|
6
7
|
# Created: 19th July 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
data/lib/recls/recls.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/recls.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Main source file for recls library
|
|
5
6
|
#
|
|
6
7
|
# Created: 19th July 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
data/lib/recls/stat.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/stat.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Defines the Recls.stat() method for the recls.Ruby library.
|
|
5
6
|
#
|
|
6
7
|
# Created: 24th July 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
data/lib/recls/util.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/util.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Utility module functions for recls library
|
|
5
6
|
#
|
|
6
7
|
# Created: 17th February 2014
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
data/lib/recls/version.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/version.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Version for recls library
|
|
5
6
|
#
|
|
6
7
|
# Created: 14th February 2014
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 20th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
12
|
+
# Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems
|
|
12
13
|
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
|
13
14
|
# All rights reserved.
|
|
14
15
|
#
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
module Recls
|
|
44
45
|
|
|
45
46
|
# Current version of the recls.Ruby library
|
|
46
|
-
VERSION = '2.13.
|
|
47
|
+
VERSION = '2.13.4'
|
|
47
48
|
|
|
48
49
|
private
|
|
49
50
|
# @!visibility private
|
data/lib/recls/ximpl/os.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/ximpl/os.rb
|
|
3
4
|
#
|
|
@@ -5,7 +6,7 @@
|
|
|
5
6
|
# recls library.
|
|
6
7
|
#
|
|
7
8
|
# Created: 16th February 2014
|
|
8
|
-
# Updated:
|
|
9
|
+
# Updated: 15th August 2026
|
|
9
10
|
#
|
|
10
11
|
# Author: Matthew Wilson
|
|
11
12
|
#
|
data/lib/recls/ximpl/unix.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/ximpl/unix.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: UNIX-specific constructs for the recls library.
|
|
5
6
|
#
|
|
6
7
|
# Created: 19th February 2014
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
12
|
+
# Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
|
|
12
13
|
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
|
13
14
|
# All rights reserved.
|
|
14
15
|
#
|
|
@@ -48,15 +49,19 @@ module Recls
|
|
|
48
49
|
# @!visibility private
|
|
49
50
|
module Ximpl # :nodoc: all
|
|
50
51
|
|
|
52
|
+
# File::Stat cannot reliably be subclassed on all Rubies (notably some
|
|
53
|
+
# Ruby 4 / MinGW builds raise TypeError: wrong instance allocation).
|
|
54
|
+
# Compose instead and forward File::Stat APIs via method_missing.
|
|
55
|
+
#
|
|
51
56
|
# @!visibility private
|
|
52
|
-
class FileStat
|
|
57
|
+
class FileStat # :nodoc:
|
|
53
58
|
|
|
54
59
|
private
|
|
55
60
|
def initialize(path)
|
|
56
61
|
|
|
57
62
|
@path = path
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
@stat = ::File::Stat.new(path)
|
|
60
65
|
end
|
|
61
66
|
|
|
62
67
|
public
|
|
@@ -74,6 +79,16 @@ module Recls
|
|
|
74
79
|
return true
|
|
75
80
|
end
|
|
76
81
|
|
|
82
|
+
def method_missing(name, *args, &block)
|
|
83
|
+
|
|
84
|
+
@stat.__send__(name, *args, &block)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def respond_to_missing?(name, include_all = false)
|
|
88
|
+
|
|
89
|
+
@stat.respond_to?(name, include_all) || super
|
|
90
|
+
end
|
|
91
|
+
|
|
77
92
|
public
|
|
78
93
|
def FileStat.stat(path)
|
|
79
94
|
|
data/lib/recls/ximpl/util.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/ximpl/util.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Internal implementation constructs for the recls library.
|
|
5
6
|
#
|
|
6
7
|
# Created: 24th July 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
12
|
+
# Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
|
|
12
13
|
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
|
13
14
|
# All rights reserved.
|
|
14
15
|
#
|
|
@@ -501,7 +502,12 @@ module Recls
|
|
|
501
502
|
|
|
502
503
|
f1_windows_root, f2_directory, dummy1, dummy2, dummy3, dummy4, dummy5 = Util.split_path(path)
|
|
503
504
|
|
|
504
|
-
|
|
505
|
+
# suppress unused warnings
|
|
506
|
+
dummy1 = dummy1
|
|
507
|
+
dummy2 = dummy2
|
|
508
|
+
dummy3 = dummy3
|
|
509
|
+
dummy4 = dummy4
|
|
510
|
+
dummy5 = dummy5
|
|
505
511
|
|
|
506
512
|
unless f1_windows_root
|
|
507
513
|
|
|
@@ -780,7 +786,7 @@ module Recls
|
|
|
780
786
|
raise ArgumentError, "`paths` must be an instance of `::Array`" if $DEBUG && !paths.is_a?(::Array)
|
|
781
787
|
raise ArgumentError, "`paths` elements must be instances of `::String`" if $DEBUG && paths.any? { |s| !s.is_a?(::String) }
|
|
782
788
|
|
|
783
|
-
abs_ix
|
|
789
|
+
abs_ix = 0
|
|
784
790
|
|
|
785
791
|
paths = paths.map { |path| '~' == path[0].to_s ? File.expand_path(path) : path }
|
|
786
792
|
|
data/lib/recls/ximpl/windows.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls/ximpl/windows.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Windows-specific constructs for the recls library.
|
|
5
6
|
#
|
|
6
7
|
# Created: 19th February 2014
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|
|
11
|
-
# Copyright (c) 2019-
|
|
12
|
+
# Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems
|
|
12
13
|
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
|
13
14
|
# All rights reserved.
|
|
14
15
|
#
|
|
@@ -39,8 +40,15 @@
|
|
|
39
40
|
|
|
40
41
|
if RUBY_VERSION >= '2'
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
begin
|
|
44
|
+
|
|
45
|
+
require 'fiddle'
|
|
46
|
+
require 'fiddle/import'
|
|
47
|
+
rescue LoadError => e
|
|
48
|
+
|
|
49
|
+
# Ruby 4+ no longer ships fiddle as a default gem.
|
|
50
|
+
raise LoadError, "#{e.message}; on Ruby 4+ Windows, add the 'fiddle' gem (see the project Gemfile)"
|
|
51
|
+
end
|
|
44
52
|
else
|
|
45
53
|
|
|
46
54
|
require 'Win32API'
|
|
@@ -211,8 +219,12 @@ module Recls
|
|
|
211
219
|
end # module Kernel32
|
|
212
220
|
end
|
|
213
221
|
|
|
222
|
+
# File::Stat cannot reliably be subclassed on all Rubies (notably some
|
|
223
|
+
# Ruby 4 / MinGW builds raise TypeError: wrong instance allocation).
|
|
224
|
+
# Compose instead and forward File::Stat APIs via method_missing.
|
|
225
|
+
#
|
|
214
226
|
# @!visibility private
|
|
215
|
-
class FileStat
|
|
227
|
+
class FileStat # :nodoc:
|
|
216
228
|
|
|
217
229
|
private
|
|
218
230
|
FILE_ATTRIBUTE_READONLY = 0x00000001
|
|
@@ -260,7 +272,7 @@ module Recls
|
|
|
260
272
|
|
|
261
273
|
@attributes = Kernel32.get_file_attributes(path)
|
|
262
274
|
|
|
263
|
-
|
|
275
|
+
@stat = ::File::Stat.new(path)
|
|
264
276
|
|
|
265
277
|
@by_handle_information = ByHandleInformation.new(path)
|
|
266
278
|
|
|
@@ -328,6 +340,17 @@ module Recls
|
|
|
328
340
|
has_attribute_? FILE_ATTRIBUTE_ENCRYPTED
|
|
329
341
|
end
|
|
330
342
|
|
|
343
|
+
# @!visibility private
|
|
344
|
+
def method_missing(name, *args, &block) # :nodoc:
|
|
345
|
+
|
|
346
|
+
@stat.__send__(name, *args, &block)
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# @!visibility private
|
|
350
|
+
def respond_to_missing?(name, include_all = false) # :nodoc:
|
|
351
|
+
|
|
352
|
+
@stat.respond_to?(name, include_all) || super
|
|
353
|
+
end
|
|
331
354
|
|
|
332
355
|
public
|
|
333
356
|
# @!visibility private
|
data/lib/recls.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# ######################################################################## #
|
|
2
3
|
# File: recls.rb
|
|
3
4
|
#
|
|
4
5
|
# Purpose: Top-level include for recls.Ruby library
|
|
5
6
|
#
|
|
6
7
|
# Created: 13th January 2012
|
|
7
|
-
# Updated:
|
|
8
|
+
# Updated: 15th August 2026
|
|
8
9
|
#
|
|
9
10
|
# Author: Matthew Wilson
|
|
10
11
|
#
|