recls-ruby 2.12.0 → 2.12.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +27 -24
- data/README.md +242 -1
- data/examples/find_files_and_directories.md +33 -30
- data/examples/find_files_and_directories.recursive.md +255 -254
- data/examples/show_hidden_files.md +4 -1
- data/examples/show_hidden_files.rb +1 -1
- data/examples/show_readonly_files.md +4 -1
- data/examples/show_readonly_files.rb +1 -1
- data/lib/recls/api.rb +76 -73
- data/lib/recls/combine_paths_1.rb +26 -23
- data/lib/recls/combine_paths_2plus.rb +32 -29
- data/lib/recls/entry.rb +277 -273
- data/lib/recls/file_search.rb +194 -193
- data/lib/recls/flags.rb +48 -45
- data/lib/recls/foreach.rb +105 -98
- data/lib/recls/obsolete.rb +85 -79
- data/lib/recls/recls.rb +19 -24
- data/lib/recls/stat.rb +137 -134
- data/lib/recls/util.rb +95 -92
- data/lib/recls/version.rb +22 -17
- data/lib/recls/ximpl/os.rb +49 -48
- data/lib/recls/ximpl/unix.rb +41 -38
- data/lib/recls/ximpl/util.rb +600 -599
- data/lib/recls/ximpl/windows.rb +142 -139
- data/lib/recls.rb +10 -9
- data/test/scratch/test_display_parts.rb +33 -33
- data/test/scratch/test_entry.rb +6 -6
- data/test/scratch/test_files_and_directories.rb +8 -8
- data/test/scratch/test_foreach.rb +10 -10
- data/test/scratch/test_module_function.rb +33 -33
- data/test/scratch/test_pattern_arrays.rb +5 -5
- data/test/scratch/test_show_dev_and_ino.rb +1 -1
- data/test/scratch/test_show_hidden.rb +3 -3
- data/test/unit/tc_recls_entries.rb +31 -31
- data/test/unit/tc_recls_entry.rb +19 -19
- data/test/unit/tc_recls_file_search.rb +32 -32
- data/test/unit/tc_recls_module.rb +25 -25
- data/test/unit/tc_recls_util.rb +161 -161
- data/test/unit/tc_recls_ximpl_util.rb +676 -676
- data/test/unit/test_all_separately.sh +1 -1
- data/test/unit/ts_all.rb +4 -4
- metadata +7 -7
data/lib/recls/ximpl/os.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
#
|
2
|
-
# File:
|
1
|
+
# ######################################################################## #
|
2
|
+
# File: recls/ximpl/os.rb
|
3
3
|
#
|
4
|
-
# Purpose:
|
5
|
-
#
|
4
|
+
# Purpose: Operating system internal implementation constructs for the
|
5
|
+
# recls library.
|
6
6
|
#
|
7
|
-
# Created:
|
8
|
-
# Updated:
|
7
|
+
# Created: 16th February 2014
|
8
|
+
# Updated: 20th April 2024
|
9
9
|
#
|
10
|
-
# Author:
|
10
|
+
# Author: Matthew Wilson
|
11
11
|
#
|
12
|
-
# Copyright (c) 2019-
|
12
|
+
# Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
|
13
13
|
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
14
14
|
# All rights reserved.
|
15
15
|
#
|
@@ -35,66 +35,67 @@
|
|
35
35
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
36
36
|
# POSSIBILITY OF SUCH DAMAGE.
|
37
37
|
#
|
38
|
-
#
|
38
|
+
# ######################################################################## #
|
39
39
|
|
40
40
|
|
41
41
|
=begin
|
42
42
|
=end
|
43
43
|
|
44
|
-
module Recls # :nodoc:
|
45
|
-
|
46
44
|
# :stopdoc:
|
47
45
|
|
48
|
-
|
46
|
+
# @!visibility private
|
47
|
+
module Recls # :nodoc:
|
49
48
|
|
50
|
-
|
49
|
+
# @!visibility private
|
50
|
+
module Ximpl # :nodoc: all
|
51
51
|
|
52
|
-
|
53
|
-
OS_IS_WINDOWS = (RUBY_PLATFORM =~ /(bccwin|cygwin|mingw|mswin|wince)/i) ? true : false
|
52
|
+
module OS # :nodoc: all
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
# @!visibility private
|
55
|
+
OS_IS_WINDOWS = (RUBY_PLATFORM =~ /(bccwin|cygwin|mingw|mswin|wince)/i) ? true : false
|
57
56
|
|
58
|
-
|
59
|
-
|
57
|
+
# @!visibility private
|
58
|
+
PATH_NAME_SEPARATOR = OS_IS_WINDOWS ? '\\' : '/'
|
60
59
|
|
61
|
-
|
62
|
-
|
60
|
+
# @!visibility private
|
61
|
+
PATH_SEPARATOR = OS_IS_WINDOWS ? ';' : ':'
|
63
62
|
|
64
|
-
|
65
|
-
|
63
|
+
# @!visibility private
|
64
|
+
WILDCARDS_ALL = OS_IS_WINDOWS ? '*' : '*'
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
return 1 if 1 == p.size
|
70
|
-
return 1 if ?/ == p[1]
|
71
|
-
return 1 if OS_IS_WINDOWS and ?\\ == p[1]
|
72
|
-
if ?. == p[1]
|
73
|
-
return 2 if 2 == p.size
|
74
|
-
return 2 if ?/ == p[2]
|
75
|
-
return 2 if OS_IS_WINDOWS and ?\\ == p[2]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
66
|
+
# @!visibility private
|
67
|
+
def OS.get_number_of_dots_dir_(p) # :nodoc:
|
79
68
|
|
80
|
-
|
81
|
-
|
69
|
+
if p
|
70
|
+
if ?. == p[0]
|
71
|
+
return 1 if 1 == p.size
|
72
|
+
return 1 if ?/ == p[1]
|
73
|
+
return 1 if OS_IS_WINDOWS and ?\\ == p[1]
|
74
|
+
if ?. == p[1]
|
75
|
+
return 2 if 2 == p.size
|
76
|
+
return 2 if ?/ == p[2]
|
77
|
+
return 2 if OS_IS_WINDOWS and ?\\ == p[2]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
82
81
|
|
83
|
-
|
84
|
-
|
82
|
+
return 0
|
83
|
+
end
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
return true if OS_IS_WINDOWS and '\\' == p
|
85
|
+
# @!visibility private
|
86
|
+
def OS.is_root_dir_(p) # :nodoc:
|
89
87
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end # module Ximpl
|
94
|
-
|
95
|
-
# :startdoc:
|
88
|
+
return nil if not p
|
89
|
+
return true if '/' == p
|
90
|
+
return true if OS_IS_WINDOWS and '\\' == p
|
96
91
|
|
92
|
+
return false
|
93
|
+
end
|
94
|
+
end # module OS
|
95
|
+
end # module Ximpl
|
97
96
|
end # module Recls
|
98
97
|
|
98
|
+
# :startdoc:
|
99
|
+
|
99
100
|
# ############################## end of file ############################# #
|
100
101
|
|
data/lib/recls/ximpl/unix.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
#
|
2
|
-
# File:
|
1
|
+
# ######################################################################## #
|
2
|
+
# File: recls/ximpl/unix.rb
|
3
3
|
#
|
4
|
-
# Purpose:
|
4
|
+
# Purpose: UNIX-specific constructs for the recls library.
|
5
5
|
#
|
6
|
-
# Created:
|
7
|
-
# Updated:
|
6
|
+
# Created: 19th February 2014
|
7
|
+
# Updated: 20th April 2024
|
8
8
|
#
|
9
|
-
# Author:
|
9
|
+
# Author: Matthew Wilson
|
10
10
|
#
|
11
|
+
# Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
|
11
12
|
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
12
13
|
# All rights reserved.
|
13
14
|
#
|
@@ -33,62 +34,64 @@
|
|
33
34
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
35
|
# POSSIBILITY OF SUCH DAMAGE.
|
35
36
|
#
|
36
|
-
#
|
37
|
+
# ######################################################################## #
|
37
38
|
|
38
39
|
|
39
40
|
require 'recls/ximpl/util'
|
40
41
|
|
42
|
+
|
41
43
|
=begin
|
42
44
|
=end
|
43
45
|
|
44
|
-
module Recls # :nodoc:
|
45
|
-
|
46
46
|
# :stopdoc:
|
47
47
|
|
48
|
-
|
48
|
+
module Recls # :nodoc:
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
# @!visibility private
|
51
|
+
module Ximpl # :nodoc: all
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
def initialize(path) # :nodoc:
|
53
|
+
# @!visibility private
|
54
|
+
class FileStat < File::Stat # :nodoc:
|
56
55
|
|
57
|
-
|
56
|
+
private
|
57
|
+
# @!visibility private
|
58
|
+
def initialize(path) # :nodoc:
|
58
59
|
|
59
|
-
|
60
|
-
end
|
60
|
+
@path = path
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
attr_reader :path # :nodoc:
|
62
|
+
super(path)
|
63
|
+
end
|
65
64
|
|
66
|
-
|
67
|
-
|
65
|
+
public
|
66
|
+
# @!visibility private
|
67
|
+
attr_reader :path # :nodoc:
|
68
68
|
|
69
|
-
|
69
|
+
# @!visibility private
|
70
|
+
def hidden? # :nodoc:
|
70
71
|
|
71
|
-
|
72
|
-
return false if '.' == basename
|
73
|
-
return false if '..' == basename
|
74
|
-
return false if ?. != basename[0]
|
72
|
+
basename = File.basename @path
|
75
73
|
|
76
|
-
|
77
|
-
|
74
|
+
return false if basename.empty?
|
75
|
+
return false if '.' == basename
|
76
|
+
return false if '..' == basename
|
77
|
+
return false if ?. != basename[0]
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
def FileStat.stat(path) # :nodoc:
|
79
|
+
return true
|
80
|
+
end
|
82
81
|
|
83
|
-
|
82
|
+
public
|
83
|
+
# @!visibility private
|
84
|
+
def FileStat.stat(path) # :nodoc:
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
Recls::Ximpl::FileStat.new(path)
|
87
|
+
|
88
|
+
end
|
89
|
+
end # class FileStat
|
90
|
+
end # module Ximpl
|
91
|
+
end # module Recls
|
88
92
|
|
89
93
|
# :startdoc:
|
90
94
|
|
91
|
-
end # module Recls
|
92
95
|
|
93
96
|
# ############################## end of file ############################# #
|
94
97
|
|