recls-ruby 2.11.0.3 → 2.12.0

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