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