recls-ruby 2.11.0 → 2.11.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 +5 -5
- 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 +75 -73
- data/lib/recls/combine_paths_1.rb +25 -23
- data/lib/recls/combine_paths_2plus.rb +31 -29
- data/lib/recls/entry.rb +276 -273
- data/lib/recls/file_search.rb +195 -193
- data/lib/recls/flags.rb +46 -45
- data/lib/recls/foreach.rb +103 -98
- data/lib/recls/obsolete.rb +80 -79
- data/lib/recls/recls.rb +16 -15
- data/lib/recls/stat.rb +136 -134
- data/lib/recls/util.rb +94 -92
- data/lib/recls/version.rb +17 -17
- data/lib/recls/ximpl/os.rb +45 -43
- data/lib/recls/ximpl/unix.rb +38 -35
- data/lib/recls/ximpl/util.rb +597 -596
- data/lib/recls/ximpl/windows.rb +139 -136
- 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 +6 -6
data/lib/recls/ximpl/windows.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
#
|
2
|
-
# File:
|
1
|
+
# ######################################################################## #
|
2
|
+
# File: recls/ximpl/windows.rb
|
3
3
|
#
|
4
|
-
# Purpose:
|
4
|
+
# Purpose: Windows-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,11 +34,12 @@
|
|
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 'Win32API'
|
40
41
|
|
42
|
+
|
41
43
|
=begin
|
42
44
|
=end
|
43
45
|
|
@@ -45,185 +47,186 @@ module Recls # :nodoc:
|
|
45
47
|
|
46
48
|
# :stopdoc:
|
47
49
|
|
48
|
-
|
50
|
+
module Ximpl # :nodoc: all
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
+
# @!visibility private
|
53
|
+
class FileStat < File::Stat # :nodoc:
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
55
|
+
private
|
56
|
+
GetFileAttributes = Win32API.new('kernel32', 'GetFileAttributes', [ 'P' ], 'I')
|
57
|
+
GetFileInformationByHandle = Win32API.new('kernel32', 'GetFileInformationByHandle', [ 'L', 'P' ], 'I')
|
58
|
+
GetShortPathName = Win32API.new('kernel32', 'GetShortPathName', [ 'P', 'P', 'L' ], 'L')
|
59
|
+
CreateFile = Win32API.new('kernel32', 'CreateFile', [ 'P', 'L', 'L', 'L', 'L', 'L', 'L' ], 'L')
|
60
|
+
CloseHandle = Win32API.new('kernel32', 'CloseHandle', [ 'L' ], 'L')
|
61
|
+
FILE_ATTRIBUTE_READONLY = 0x00000001
|
62
|
+
FILE_ATTRIBUTE_HIDDEN = 0x00000002
|
63
|
+
FILE_ATTRIBUTE_SYSTEM = 0x00000004
|
64
|
+
FILE_ATTRIBUTE_DIRECTORY = 0x00000010
|
65
|
+
FILE_ATTRIBUTE_ARCHIVE = 0x00000020
|
66
|
+
FILE_ATTRIBUTE_DEVICE = 0x00000040
|
67
|
+
FILE_ATTRIBUTE_NORMAL = 0x00000080
|
68
|
+
FILE_ATTRIBUTE_TEMPORARY = 0x00000100
|
69
|
+
FILE_ATTRIBUTE_COMPRESSED = 0x00000800
|
70
|
+
FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
OPEN_EXISTING = 0x00000003
|
73
|
+
FILE_FLAG_OVERLAPPED = 0x40000000
|
74
|
+
NULL = 0x00000000
|
75
|
+
INVALID_HANDLE_VALUE = 0xFFFFFFFF
|
74
76
|
|
75
|
-
|
77
|
+
MAX_PATH = 260
|
76
78
|
|
77
|
-
|
79
|
+
BHFI_pack_string = 'LQQQLLLLLL'
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
# @!visibility private
|
82
|
+
class ByHandleInformation # :nodoc:
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
+
# @!visibility private
|
85
|
+
def initialize(path) # :nodoc:
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
@volume_id = 0
|
88
|
+
@file_index = 0
|
89
|
+
@num_links = 0
|
88
90
|
|
89
|
-
|
90
|
-
|
91
|
-
|
91
|
+
# for some reason not forcing this new string causes 'can't modify frozen string (TypeError)' (in Ruby 1.8.x)
|
92
|
+
hFile = CreateFile.call("#{path}", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
93
|
+
if INVALID_HANDLE_VALUE != hFile
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
begin
|
96
|
+
bhfi = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
|
97
|
+
bhfi = bhfi.pack(BHFI_pack_string)
|
96
98
|
|
97
|
-
|
99
|
+
if GetFileInformationByHandle.call(hFile, bhfi)
|
98
100
|
|
99
|
-
|
101
|
+
bhfi = bhfi.unpack(BHFI_pack_string)
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
103
|
+
@volume_id = bhfi[4]
|
104
|
+
@file_index = (bhfi[8] << 32) | bhfi[9]
|
105
|
+
@num_links = bhfi[7]
|
106
|
+
else
|
107
|
+
end
|
108
|
+
ensure
|
109
|
+
CloseHandle.call(hFile)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
111
113
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
# @!visibility private
|
115
|
+
attr_reader :volume_id
|
116
|
+
# @!visibility private
|
117
|
+
attr_reader :file_index
|
118
|
+
# @!visibility private
|
119
|
+
attr_reader :num_links
|
120
|
+
end
|
119
121
|
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
private
|
123
|
+
# @!visibility private
|
124
|
+
def has_attribute_? (attr) # :nodoc:
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
+
0 != (attr & @attributes)
|
127
|
+
end
|
126
128
|
|
127
|
-
|
128
|
-
|
129
|
-
|
129
|
+
private
|
130
|
+
# @!visibility private
|
131
|
+
def initialize(path) # :nodoc:
|
130
132
|
|
131
|
-
|
133
|
+
@path = path
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
+
# for some reason not forcing this new string causes 'can't modify frozen string (TypeError)'
|
136
|
+
attributes = GetFileAttributes.call("#{path}")
|
135
137
|
|
136
|
-
|
138
|
+
if 0xffffffff == attributes
|
137
139
|
|
138
|
-
|
139
|
-
|
140
|
+
@attributes = 0
|
141
|
+
else
|
140
142
|
|
141
|
-
|
142
|
-
|
143
|
+
@attributes = attributes
|
144
|
+
end
|
143
145
|
|
144
|
-
|
146
|
+
super(path)
|
145
147
|
|
146
|
-
|
148
|
+
@by_handle_information = ByHandleInformation.new(path)
|
147
149
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
150
|
+
buff = ' ' * MAX_PATH
|
151
|
+
# not forcing this new string causes 'can't modify frozen string (TypeError)'
|
152
|
+
n = GetShortPathName.call("#{path}", buff, buff.length)
|
153
|
+
@short_path = (0 == n) ? nil : buff[0...n]
|
154
|
+
end
|
153
155
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
156
|
+
public
|
157
|
+
# @!visibility private
|
158
|
+
attr_reader :attributes
|
159
|
+
# @!visibility private
|
160
|
+
attr_reader :path
|
161
|
+
# @!visibility private
|
162
|
+
attr_reader :by_handle_information
|
163
|
+
# @!visibility private
|
164
|
+
attr_reader :short_path
|
163
165
|
|
164
|
-
|
165
|
-
|
166
|
+
# @!visibility private
|
167
|
+
def hidden? # :nodoc:
|
166
168
|
|
167
|
-
|
168
|
-
|
169
|
+
0 != (FILE_ATTRIBUTE_HIDDEN & @attributes)
|
170
|
+
end
|
169
171
|
|
170
|
-
|
172
|
+
# Windows-specific attributes
|
171
173
|
|
172
|
-
|
173
|
-
|
174
|
+
# @!visibility private
|
175
|
+
def system? # :nodoc:
|
174
176
|
|
175
|
-
|
176
|
-
|
177
|
+
has_attribute_? FILE_ATTRIBUTE_SYSTEM
|
178
|
+
end
|
177
179
|
|
178
|
-
|
179
|
-
|
180
|
+
# @!visibility private
|
181
|
+
def archive? # :nodoc:
|
180
182
|
|
181
|
-
|
182
|
-
|
183
|
+
has_attribute_? FILE_ATTRIBUTE_ARCHIVE
|
184
|
+
end
|
183
185
|
|
184
|
-
|
185
|
-
|
186
|
+
# @!visibility private
|
187
|
+
def device? # :nodoc:
|
186
188
|
|
187
|
-
|
188
|
-
|
189
|
+
has_attribute_? FILE_ATTRIBUTE_DEVICE
|
190
|
+
end
|
189
191
|
|
190
|
-
|
191
|
-
|
192
|
+
# @!visibility private
|
193
|
+
def normal? # :nodoc:
|
192
194
|
|
193
|
-
|
194
|
-
|
195
|
+
has_attribute_? FILE_ATTRIBUTE_NORMAL
|
196
|
+
end
|
195
197
|
|
196
|
-
|
197
|
-
|
198
|
+
# @!visibility private
|
199
|
+
def temporary? # :nodoc:
|
198
200
|
|
199
|
-
|
200
|
-
|
201
|
+
has_attribute_? FILE_ATTRIBUTE_TEMPORARY
|
202
|
+
end
|
201
203
|
|
202
|
-
|
203
|
-
|
204
|
+
# @!visibility private
|
205
|
+
def compressed? # :nodoc:
|
204
206
|
|
205
|
-
|
206
|
-
|
207
|
+
has_attribute_? FILE_ATTRIBUTE_COMPRESSED
|
208
|
+
end
|
207
209
|
|
208
|
-
|
209
|
-
|
210
|
+
# @!visibility private
|
211
|
+
def encrypted? # :nodoc:
|
210
212
|
|
211
|
-
|
212
|
-
|
213
|
+
has_attribute_? FILE_ATTRIBUTE_ENCRYPTED
|
214
|
+
end
|
213
215
|
|
214
216
|
|
215
|
-
|
216
|
-
|
217
|
-
|
217
|
+
public
|
218
|
+
# @!visibility private
|
219
|
+
def FileStat.stat(path) # :nodoc:
|
218
220
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
221
|
+
Recls::Ximpl::FileStat.new(path)
|
222
|
+
end
|
223
|
+
end # class FileStat
|
224
|
+
end # module Ximpl
|
223
225
|
|
224
226
|
# :startdoc:
|
225
227
|
|
226
228
|
end # module Recls
|
227
229
|
|
230
|
+
|
228
231
|
# ############################## end of file ############################# #
|
229
232
|
|
data/lib/recls.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
#
|
2
|
-
# File:
|
1
|
+
# ######################################################################## #
|
2
|
+
# File: recls.rb
|
3
3
|
#
|
4
|
-
# Purpose:
|
4
|
+
# Purpose: Top-level include for recls.Ruby library
|
5
5
|
#
|
6
|
-
# Created:
|
7
|
-
# Updated:
|
6
|
+
# Created: 13th January 2012
|
7
|
+
# Updated: 20th April 2024
|
8
8
|
#
|
9
|
-
# Author:
|
9
|
+
# Author: Matthew Wilson
|
10
10
|
#
|
11
|
-
# Copyright (c)
|
11
|
+
# Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
|
12
|
+
# Copyright (c) 2012-2019, Matthew Wilson and Synesis Software
|
12
13
|
# All rights reserved.
|
13
14
|
#
|
14
15
|
# Redistribution and use in source and binary forms, with or without
|
@@ -33,11 +34,11 @@
|
|
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/recls'
|
40
41
|
|
41
|
-
# ############################## end of file ############################# #
|
42
42
|
|
43
|
+
# ############################## end of file ############################# #
|
43
44
|
|
@@ -6,41 +6,41 @@ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
|
|
6
6
|
|
7
7
|
require 'recls'
|
8
8
|
|
9
|
-
root_dir
|
10
|
-
patterns
|
9
|
+
root_dir = '.'
|
10
|
+
patterns = Recls::WILDCARDS_ALL
|
11
11
|
|
12
12
|
Recls::FileSearch.new(root_dir, patterns, Recls::FILES | Recls::RECURSIVE).each do |fe|
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
14
|
+
drive = fe.drive || ''
|
15
|
+
|
16
|
+
puts
|
17
|
+
puts "entry:"
|
18
|
+
puts fe.path
|
19
|
+
puts fe.short_path
|
20
|
+
puts fe.directory_path
|
21
|
+
puts drive
|
22
|
+
puts "".ljust(drive ? drive.size : 0) + fe.directory.to_s
|
23
|
+
puts "".ljust(fe.directory_path.size) + fe.file.to_s
|
24
|
+
puts "".ljust(fe.directory_path.size) + fe.file_short_name.to_s
|
25
|
+
puts "".ljust(fe.directory_path.size) + fe.stem.to_s
|
26
|
+
puts "".ljust(fe.directory_path.size + fe.stem.size) + fe.extension.to_s
|
27
|
+
n = drive.size
|
28
|
+
fe.directory_parts.each do |part|
|
29
|
+
|
30
|
+
puts "".ljust(n) + part
|
31
|
+
n += part.size
|
32
|
+
end
|
33
|
+
|
34
|
+
puts fe.search_directory
|
35
|
+
puts "".ljust(fe.search_directory.size) + fe.search_relative_path.to_s
|
36
|
+
puts "".ljust(fe.search_directory.size) + fe.search_relative_directory_path.to_s
|
37
|
+
puts "".ljust(fe.search_directory.size) + fe.search_relative_directory.to_s
|
38
|
+
|
39
|
+
n = fe.search_directory.size
|
40
|
+
fe.search_relative_directory_parts.each do |part|
|
41
|
+
|
42
|
+
puts "".ljust(n) + part
|
43
|
+
n += part.size
|
44
|
+
end
|
45
45
|
end
|
46
46
|
|
data/test/scratch/test_entry.rb
CHANGED
@@ -22,7 +22,7 @@ puts "\t#{'f.directory'.ljust(20)}\t#{f.directory}"
|
|
22
22
|
directory_parts = f.directory_parts
|
23
23
|
puts "\t#{'f.directory_parts'.ljust(20)}\t[#{directory_parts.size}]"
|
24
24
|
directory_parts.each do |part|
|
25
|
-
|
25
|
+
puts "\t#{''.ljust(20)}\t\t#{part}"
|
26
26
|
end
|
27
27
|
puts "\t#{'f.file_full_name'.ljust(20)}\t#{f.file_full_name}"
|
28
28
|
puts "\t#{'f.file_short_name'.ljust(20)}\t#{f.file_short_name}"
|
@@ -36,7 +36,7 @@ puts "\t#{'f.search_relative_directory_path'.ljust(20)}\t#{f.search_relative_dir
|
|
36
36
|
search_relative_directory_parts = f.search_relative_directory_parts
|
37
37
|
puts "\t#{'f.search_relative_directory_parts'.ljust(20)}\t[#{search_relative_directory_parts.size}]"
|
38
38
|
search_relative_directory_parts.each do |part|
|
39
|
-
|
39
|
+
puts "\t#{''.ljust(20)}\t\t#{part}"
|
40
40
|
end
|
41
41
|
|
42
42
|
puts "\t#{'f.size'.ljust(20)}\t#{f.size}"
|
@@ -66,8 +66,8 @@ puts "directories:"
|
|
66
66
|
num_directories = 0
|
67
67
|
Recls::FileSearch.new('.', '*', Recls::DIRECTORIES).each do |fe|
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
num_directories += 1
|
70
|
+
puts "\t[#{fe.search_relative_path}]"
|
71
71
|
end
|
72
72
|
puts " #{num_directories} directories"
|
73
73
|
|
@@ -76,8 +76,8 @@ puts "files:"
|
|
76
76
|
num_files = 0
|
77
77
|
Recls::FileSearch.new('.', '*.rb', Recls::RECURSIVE | Recls::FILES).each do |fe|
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
num_files += 1
|
80
|
+
puts "\t<#{fe.search_relative_path}>"
|
81
81
|
end
|
82
82
|
puts " #{num_files} file(s)"
|
83
83
|
|
@@ -12,15 +12,15 @@ puts
|
|
12
12
|
|
13
13
|
Recls::FileSearch.new(nil, nil, Recls::FILES | Recls::DIRECTORIES | Recls::RECURSIVE).each do |fe|
|
14
14
|
|
15
|
-
|
15
|
+
path = fe.search_relative_path
|
16
16
|
|
17
|
-
|
17
|
+
if fe.directory?
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
puts path + '/'
|
20
|
+
else
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
puts path
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
puts
|
@@ -29,8 +29,8 @@ puts
|
|
29
29
|
|
30
30
|
Recls::FileSearch.new(nil, nil, Recls::FILES | Recls::DIRECTORIES | Recls::RECURSIVE | Recls::MARK_DIRECTORIES).each do |fe|
|
31
31
|
|
32
|
-
|
32
|
+
path = fe.search_relative_path
|
33
33
|
|
34
|
-
|
34
|
+
puts path
|
35
35
|
end
|
36
36
|
|
@@ -11,13 +11,13 @@ puts "with given block:"
|
|
11
11
|
count_1 = 0
|
12
12
|
Recls.foreach(Recls::FileSearch.new(nil, '*.rb', Recls::RECURSIVE)).each do |line, line_number, fe|
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
line = line.chomp
|
15
|
+
line_number = 1 + line_number
|
16
16
|
|
17
|
-
|
17
|
+
puts "#{fe.search_relative_path}(#{line_number + 1}): #{line}"
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
count_1 += 1
|
20
|
+
break if 20 == count_1
|
21
21
|
end
|
22
22
|
|
23
23
|
puts
|
@@ -26,13 +26,13 @@ e = Recls.foreach(Recls::FileSearch.new(nil, '*.rb', Recls::RECURSIVE))
|
|
26
26
|
count_2 = 0
|
27
27
|
e.each do |line, line_number, fe|
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
line = line.chomp
|
30
|
+
line_number = 1 + line_number
|
31
31
|
|
32
|
-
|
32
|
+
puts "#{fe.search_relative_path}(#{line_number + 1}): #{line}"
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
count_2 += 1
|
35
|
+
break if 20 == count_2
|
36
36
|
end
|
37
37
|
|
38
38
|
|
@@ -6,41 +6,41 @@ $:.unshift File.join(File.dirname(__FILE__), '../..', 'lib')
|
|
6
6
|
|
7
7
|
require 'recls'
|
8
8
|
|
9
|
-
root_dir
|
10
|
-
patterns
|
9
|
+
root_dir = '.'
|
10
|
+
patterns = Recls::WILDCARDS_ALL
|
11
11
|
|
12
12
|
Recls.FileSearch(root_dir, patterns, flags: Recls::FILES).each do |fe|
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
14
|
+
drive = fe.drive || ''
|
15
|
+
|
16
|
+
puts
|
17
|
+
puts "entry:"
|
18
|
+
puts fe.path
|
19
|
+
puts fe.short_path
|
20
|
+
puts fe.directory_path
|
21
|
+
puts drive
|
22
|
+
puts "".ljust(drive ? drive.size : 0) + fe.directory.to_s
|
23
|
+
puts "".ljust(fe.directory_path.size) + fe.file.to_s
|
24
|
+
puts "".ljust(fe.directory_path.size) + fe.file_short_name.to_s
|
25
|
+
puts "".ljust(fe.directory_path.size) + fe.stem.to_s
|
26
|
+
puts "".ljust(fe.directory_path.size + fe.stem.size) + fe.extension.to_s
|
27
|
+
n = drive.size
|
28
|
+
fe.directory_parts.each do |part|
|
29
|
+
|
30
|
+
puts "".ljust(n) + part
|
31
|
+
n += part.size
|
32
|
+
end
|
33
|
+
|
34
|
+
puts fe.search_directory
|
35
|
+
puts "".ljust(fe.search_directory.size) + fe.search_relative_path.to_s
|
36
|
+
puts "".ljust(fe.search_directory.size) + fe.search_relative_directory_path.to_s
|
37
|
+
puts "".ljust(fe.search_directory.size) + fe.search_relative_directory.to_s
|
38
|
+
|
39
|
+
n = fe.search_directory.size
|
40
|
+
fe.search_relative_directory_parts.each do |part|
|
41
|
+
|
42
|
+
puts "".ljust(n) + part
|
43
|
+
n += part.size
|
44
|
+
end
|
45
45
|
end
|
46
46
|
|