fileutils 1.0.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/Rakefile +12 -3
- data/fileutils.gemspec +18 -12
- data/lib/fileutils.rb +288 -155
- metadata +10 -29
- data/.gitignore +0 -9
- data/.travis.yml +0 -6
- data/Gemfile +0 -4
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67fa33577498dff5705331ce6453a3c11ff34d209343310f647d4cb404158617
|
4
|
+
data.tar.gz: 4608e153f0c69749fbf7e4d456388c44fdba1a3a99f5b328c71c283ccd7ca5a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db0b5ce907f782c5ba306ca0a8811c825ec1f97a47731ccc08b2ddc7e13160d7d40986afd1b744cef7b941b2bef2f1c1c4017eb8fc616e8695b506d5ce8cc8ae
|
7
|
+
data.tar.gz: ccbb52c0a277e03e29dfff22e5bb26b3dc30e7ede6db803f130047bb039cb12161d7f3ecafac5f0956959fde6276b16c68085f30be7c8edae019e7d313301b53
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,19 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
3
|
|
4
|
+
JRuby.objectspace = true if RUBY_PLATFORM == 'java'
|
5
|
+
|
4
6
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test
|
6
|
-
t.
|
7
|
-
t.test_files = FileList[
|
7
|
+
t.libs << "test/lib"
|
8
|
+
t.ruby_opts << "-rhelper"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
task :sync_tool do
|
13
|
+
require 'fileutils'
|
14
|
+
FileUtils.cp "../ruby/tool/lib/test/unit/core_assertions.rb", "./test/lib"
|
15
|
+
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
|
16
|
+
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
|
8
17
|
end
|
9
18
|
|
10
19
|
task :default => :test
|
data/fileutils.gemspec
CHANGED
@@ -1,25 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source_version = ["", "lib/"].find do |dir|
|
4
|
+
begin
|
5
|
+
break File.open(File.join(__dir__, "#{dir}fileutils.rb")) {|f|
|
6
|
+
f.gets("\n VERSION = ")
|
7
|
+
f.gets[/\s*"(.+)"/, 1]
|
8
|
+
}
|
9
|
+
rescue Errno::ENOENT
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
2
13
|
Gem::Specification.new do |s|
|
3
14
|
s.name = "fileutils"
|
4
|
-
s.version =
|
5
|
-
s.date = '2017-12-22'
|
15
|
+
s.version = source_version
|
6
16
|
s.summary = "Several file utility methods for copying, moving, removing, etc."
|
7
17
|
s.description = "Several file utility methods for copying, moving, removing, etc."
|
8
18
|
|
9
19
|
s.require_path = %w{lib}
|
10
|
-
s.files = ["
|
11
|
-
s.required_ruby_version = ">= 2.
|
20
|
+
s.files = ["LICENSE.txt", "README.md", "Rakefile", "fileutils.gemspec", "lib/fileutils.rb"]
|
21
|
+
s.required_ruby_version = ">= 2.3.0"
|
12
22
|
|
13
23
|
s.authors = ["Minero Aoki"]
|
14
24
|
s.email = [nil]
|
15
25
|
s.homepage = "https://github.com/ruby/fileutils"
|
16
|
-
s.
|
17
|
-
|
18
|
-
if s.respond_to?(:metadata=)
|
19
|
-
s.metadata = {
|
20
|
-
"source_code_uri" => "https://github.com/ruby/fileutils"
|
21
|
-
}
|
22
|
-
end
|
26
|
+
s.licenses = ["Ruby", "BSD-2-Clause"]
|
23
27
|
|
24
|
-
s.
|
28
|
+
s.metadata = {
|
29
|
+
"source_code_uri" => "https://github.com/ruby/fileutils"
|
30
|
+
}
|
25
31
|
end
|
data/lib/fileutils.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rbconfig'
|
5
|
+
rescue LoadError
|
6
|
+
# for make mjit-headers
|
7
|
+
end
|
8
|
+
|
2
9
|
#
|
3
10
|
# = fileutils.rb
|
4
11
|
#
|
@@ -15,48 +22,58 @@
|
|
15
22
|
#
|
16
23
|
# require 'fileutils'
|
17
24
|
#
|
18
|
-
# FileUtils.cd(dir, options)
|
19
|
-
# FileUtils.cd(dir, options) {|dir| block }
|
25
|
+
# FileUtils.cd(dir, **options)
|
26
|
+
# FileUtils.cd(dir, **options) {|dir| block }
|
20
27
|
# FileUtils.pwd()
|
21
|
-
# FileUtils.mkdir(dir, options)
|
22
|
-
# FileUtils.mkdir(list, options)
|
23
|
-
# FileUtils.mkdir_p(dir, options)
|
24
|
-
# FileUtils.mkdir_p(list, options)
|
25
|
-
# FileUtils.rmdir(dir, options)
|
26
|
-
# FileUtils.rmdir(list, options)
|
27
|
-
# FileUtils.ln(target, link, options)
|
28
|
-
# FileUtils.ln(targets, dir, options)
|
29
|
-
# FileUtils.ln_s(target, link, options)
|
30
|
-
# FileUtils.ln_s(targets, dir, options)
|
31
|
-
# FileUtils.ln_sf(target, link, options)
|
32
|
-
# FileUtils.cp(src, dest, options)
|
33
|
-
# FileUtils.cp(list, dir, options)
|
34
|
-
# FileUtils.cp_r(src, dest, options)
|
35
|
-
# FileUtils.cp_r(list, dir, options)
|
36
|
-
# FileUtils.mv(src, dest, options)
|
37
|
-
# FileUtils.mv(list, dir, options)
|
38
|
-
# FileUtils.rm(list, options)
|
39
|
-
# FileUtils.rm_r(list, options)
|
40
|
-
# FileUtils.rm_rf(list, options)
|
41
|
-
# FileUtils.install(src, dest, options)
|
42
|
-
# FileUtils.chmod(mode, list, options)
|
43
|
-
# FileUtils.chmod_R(mode, list, options)
|
44
|
-
# FileUtils.chown(user, group, list, options)
|
45
|
-
# FileUtils.chown_R(user, group, list, options)
|
46
|
-
# FileUtils.touch(list, options)
|
28
|
+
# FileUtils.mkdir(dir, **options)
|
29
|
+
# FileUtils.mkdir(list, **options)
|
30
|
+
# FileUtils.mkdir_p(dir, **options)
|
31
|
+
# FileUtils.mkdir_p(list, **options)
|
32
|
+
# FileUtils.rmdir(dir, **options)
|
33
|
+
# FileUtils.rmdir(list, **options)
|
34
|
+
# FileUtils.ln(target, link, **options)
|
35
|
+
# FileUtils.ln(targets, dir, **options)
|
36
|
+
# FileUtils.ln_s(target, link, **options)
|
37
|
+
# FileUtils.ln_s(targets, dir, **options)
|
38
|
+
# FileUtils.ln_sf(target, link, **options)
|
39
|
+
# FileUtils.cp(src, dest, **options)
|
40
|
+
# FileUtils.cp(list, dir, **options)
|
41
|
+
# FileUtils.cp_r(src, dest, **options)
|
42
|
+
# FileUtils.cp_r(list, dir, **options)
|
43
|
+
# FileUtils.mv(src, dest, **options)
|
44
|
+
# FileUtils.mv(list, dir, **options)
|
45
|
+
# FileUtils.rm(list, **options)
|
46
|
+
# FileUtils.rm_r(list, **options)
|
47
|
+
# FileUtils.rm_rf(list, **options)
|
48
|
+
# FileUtils.install(src, dest, **options)
|
49
|
+
# FileUtils.chmod(mode, list, **options)
|
50
|
+
# FileUtils.chmod_R(mode, list, **options)
|
51
|
+
# FileUtils.chown(user, group, list, **options)
|
52
|
+
# FileUtils.chown_R(user, group, list, **options)
|
53
|
+
# FileUtils.touch(list, **options)
|
54
|
+
#
|
55
|
+
# Possible <tt>options</tt> are:
|
47
56
|
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
# <tt>:
|
51
|
-
#
|
57
|
+
# <tt>:force</tt> :: forced operation (rewrite files if exist, remove
|
58
|
+
# directories if not empty, etc.);
|
59
|
+
# <tt>:verbose</tt> :: print command to be run, in bash syntax, before
|
60
|
+
# performing it;
|
61
|
+
# <tt>:preserve</tt> :: preserve object's group, user and modification
|
62
|
+
# time on copying;
|
63
|
+
# <tt>:noop</tt> :: no changes are made (usable in combination with
|
64
|
+
# <tt>:verbose</tt> which will print the command to run)
|
65
|
+
#
|
66
|
+
# Each method documents the options that it honours. See also ::commands,
|
67
|
+
# ::options and ::options_of methods to introspect which command have which
|
68
|
+
# options.
|
52
69
|
#
|
53
70
|
# All methods that have the concept of a "source" file or directory can take
|
54
71
|
# either one file or a list of files in that argument. See the method
|
55
72
|
# documentation for examples.
|
56
73
|
#
|
57
|
-
# There are some `low level' methods, which do not accept
|
74
|
+
# There are some `low level' methods, which do not accept keyword arguments:
|
58
75
|
#
|
59
|
-
# FileUtils.copy_entry(src, dest, preserve = false,
|
76
|
+
# FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
|
60
77
|
# FileUtils.copy_file(src, dest, preserve = false, dereference = true)
|
61
78
|
# FileUtils.copy_stream(srcstream, deststream)
|
62
79
|
# FileUtils.remove_entry(path, force = false)
|
@@ -84,10 +101,8 @@
|
|
84
101
|
# files/directories. This equates to passing the <tt>:noop</tt> and
|
85
102
|
# <tt>:verbose</tt> flags to methods in FileUtils.
|
86
103
|
#
|
87
|
-
|
88
104
|
module FileUtils
|
89
|
-
|
90
|
-
VERSION = "1.0.2"
|
105
|
+
VERSION = "1.5.0"
|
91
106
|
|
92
107
|
def self.private_module_function(name) #:nodoc:
|
93
108
|
module_function name
|
@@ -108,19 +123,22 @@ module FileUtils
|
|
108
123
|
#
|
109
124
|
# Changes the current directory to the directory +dir+.
|
110
125
|
#
|
111
|
-
# If this method is called with block, resumes to the
|
112
|
-
# working directory after the block execution finished.
|
126
|
+
# If this method is called with block, resumes to the previous
|
127
|
+
# working directory after the block execution has finished.
|
113
128
|
#
|
114
|
-
# FileUtils.cd('/'
|
129
|
+
# FileUtils.cd('/') # change directory
|
115
130
|
#
|
116
|
-
# FileUtils.cd('/')
|
131
|
+
# FileUtils.cd('/', verbose: true) # change directory and report it
|
132
|
+
#
|
133
|
+
# FileUtils.cd('/') do # change directory
|
117
134
|
# # ... # do something
|
118
135
|
# end # return to original directory
|
119
136
|
#
|
120
137
|
def cd(dir, verbose: nil, &block) # :yield: dir
|
121
138
|
fu_output_message "cd #{dir}" if verbose
|
122
|
-
Dir.chdir(dir, &block)
|
139
|
+
result = Dir.chdir(dir, &block)
|
123
140
|
fu_output_message 'cd -' if verbose and block
|
141
|
+
result
|
124
142
|
end
|
125
143
|
module_function :cd
|
126
144
|
|
@@ -155,9 +173,9 @@ module FileUtils
|
|
155
173
|
# Creates one or more directories.
|
156
174
|
#
|
157
175
|
# FileUtils.mkdir 'test'
|
158
|
-
# FileUtils.mkdir %w(
|
159
|
-
# FileUtils.mkdir 'notexist', :
|
160
|
-
# FileUtils.mkdir 'tmp', :
|
176
|
+
# FileUtils.mkdir %w(tmp data)
|
177
|
+
# FileUtils.mkdir 'notexist', noop: true # Does not really create.
|
178
|
+
# FileUtils.mkdir 'tmp', mode: 0700
|
161
179
|
#
|
162
180
|
def mkdir(list, mode: nil, noop: nil, verbose: nil)
|
163
181
|
list = fu_list(list)
|
@@ -176,7 +194,7 @@ module FileUtils
|
|
176
194
|
#
|
177
195
|
# FileUtils.mkdir_p '/usr/local/lib/ruby'
|
178
196
|
#
|
179
|
-
# causes to make following directories, if
|
197
|
+
# causes to make following directories, if they do not exist.
|
180
198
|
#
|
181
199
|
# * /usr
|
182
200
|
# * /usr/local
|
@@ -190,7 +208,9 @@ module FileUtils
|
|
190
208
|
fu_output_message "mkdir -p #{mode ? ('-m %03o ' % mode) : ''}#{list.join ' '}" if verbose
|
191
209
|
return *list if noop
|
192
210
|
|
193
|
-
list.
|
211
|
+
list.each do |item|
|
212
|
+
path = remove_trailing_slash(item)
|
213
|
+
|
194
214
|
# optimize for the most common case
|
195
215
|
begin
|
196
216
|
fu_mkdir path, mode
|
@@ -203,8 +223,9 @@ module FileUtils
|
|
203
223
|
until path == stack.last # dirname("/")=="/", dirname("C:/")=="C:/"
|
204
224
|
stack.push path
|
205
225
|
path = File.dirname(path)
|
226
|
+
break if File.directory?(path)
|
206
227
|
end
|
207
|
-
stack.pop
|
228
|
+
stack.pop if path == stack.last # root directory should exist
|
208
229
|
stack.reverse_each do |dir|
|
209
230
|
begin
|
210
231
|
fu_mkdir dir, mode
|
@@ -240,7 +261,7 @@ module FileUtils
|
|
240
261
|
# FileUtils.rmdir 'somedir'
|
241
262
|
# FileUtils.rmdir %w(somedir anydir otherdir)
|
242
263
|
# # Does not really remove directory; outputs message.
|
243
|
-
# FileUtils.rmdir 'somedir', :
|
264
|
+
# FileUtils.rmdir 'somedir', verbose: true, noop: true
|
244
265
|
#
|
245
266
|
def rmdir(list, parents: nil, noop: nil, verbose: nil)
|
246
267
|
list = fu_list(list)
|
@@ -269,7 +290,7 @@ module FileUtils
|
|
269
290
|
#
|
270
291
|
# In the first form, creates a hard link +link+ which points to +target+.
|
271
292
|
# If +link+ already exists, raises Errno::EEXIST.
|
272
|
-
# But if the
|
293
|
+
# But if the +force+ option is set, overwrites +link+.
|
273
294
|
#
|
274
295
|
# FileUtils.ln 'gcc', 'cc', verbose: true
|
275
296
|
# FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
|
@@ -295,6 +316,39 @@ module FileUtils
|
|
295
316
|
alias link ln
|
296
317
|
module_function :link
|
297
318
|
|
319
|
+
#
|
320
|
+
# Hard link +src+ to +dest+. If +src+ is a directory, this method links
|
321
|
+
# all its contents recursively. If +dest+ is a directory, links
|
322
|
+
# +src+ to +dest/src+.
|
323
|
+
#
|
324
|
+
# +src+ can be a list of files.
|
325
|
+
#
|
326
|
+
# If +dereference_root+ is true, this method dereference tree root.
|
327
|
+
#
|
328
|
+
# If +remove_destination+ is true, this method removes each destination file before copy.
|
329
|
+
#
|
330
|
+
# FileUtils.rm_r site_ruby + '/mylib', force: true
|
331
|
+
# FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
|
332
|
+
#
|
333
|
+
# # Examples of linking several files to target directory.
|
334
|
+
# FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
335
|
+
# FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
|
336
|
+
#
|
337
|
+
# # If you want to link all contents of a directory instead of the
|
338
|
+
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
339
|
+
# # use the following code.
|
340
|
+
# FileUtils.cp_lr 'src/.', 'dest' # cp_lr('src', 'dest') makes dest/src, but this doesn't.
|
341
|
+
#
|
342
|
+
def cp_lr(src, dest, noop: nil, verbose: nil,
|
343
|
+
dereference_root: true, remove_destination: false)
|
344
|
+
fu_output_message "cp -lr#{remove_destination ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if verbose
|
345
|
+
return if noop
|
346
|
+
fu_each_src_dest(src, dest) do |s, d|
|
347
|
+
link_entry s, d, dereference_root, remove_destination
|
348
|
+
end
|
349
|
+
end
|
350
|
+
module_function :cp_lr
|
351
|
+
|
298
352
|
#
|
299
353
|
# :call-seq:
|
300
354
|
# FileUtils.ln_s(target, link, force: nil, noop: nil, verbose: nil)
|
@@ -303,7 +357,7 @@ module FileUtils
|
|
303
357
|
#
|
304
358
|
# In the first form, creates a symbolic link +link+ which points to +target+.
|
305
359
|
# If +link+ already exists, raises Errno::EEXIST.
|
306
|
-
# But if the
|
360
|
+
# But if the <tt>force</tt> option is set, overwrites +link+.
|
307
361
|
#
|
308
362
|
# FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
|
309
363
|
# FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
|
@@ -341,6 +395,26 @@ module FileUtils
|
|
341
395
|
end
|
342
396
|
module_function :ln_sf
|
343
397
|
|
398
|
+
#
|
399
|
+
# Hard links a file system entry +src+ to +dest+.
|
400
|
+
# If +src+ is a directory, this method links its contents recursively.
|
401
|
+
#
|
402
|
+
# Both of +src+ and +dest+ must be a path name.
|
403
|
+
# +src+ must exist, +dest+ must not exist.
|
404
|
+
#
|
405
|
+
# If +dereference_root+ is true, this method dereferences the tree root.
|
406
|
+
#
|
407
|
+
# If +remove_destination+ is true, this method removes each destination file before copy.
|
408
|
+
#
|
409
|
+
def link_entry(src, dest, dereference_root = false, remove_destination = false)
|
410
|
+
Entry_.new(src, nil, dereference_root).traverse do |ent|
|
411
|
+
destent = Entry_.new(dest, ent.rel, false)
|
412
|
+
File.unlink destent.path if remove_destination && File.file?(destent.path)
|
413
|
+
ent.link destent.path
|
414
|
+
end
|
415
|
+
end
|
416
|
+
module_function :link_entry
|
417
|
+
|
344
418
|
#
|
345
419
|
# Copies a file content +src+ to +dest+. If +dest+ is a directory,
|
346
420
|
# copies +src+ to +dest/src+.
|
@@ -349,7 +423,7 @@ module FileUtils
|
|
349
423
|
#
|
350
424
|
# FileUtils.cp 'eval.c', 'eval.c.org'
|
351
425
|
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
|
352
|
-
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :
|
426
|
+
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', verbose: true
|
353
427
|
# FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
|
354
428
|
#
|
355
429
|
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
|
@@ -371,13 +445,17 @@ module FileUtils
|
|
371
445
|
#
|
372
446
|
# +src+ can be a list of files.
|
373
447
|
#
|
448
|
+
# If +dereference_root+ is true, this method dereference tree root.
|
449
|
+
#
|
450
|
+
# If +remove_destination+ is true, this method removes each destination file before copy.
|
451
|
+
#
|
374
452
|
# # Installing Ruby library "mylib" under the site_ruby
|
375
|
-
# FileUtils.rm_r site_ruby + '/mylib', :
|
453
|
+
# FileUtils.rm_r site_ruby + '/mylib', force: true
|
376
454
|
# FileUtils.cp_r 'lib/', site_ruby + '/mylib'
|
377
455
|
#
|
378
456
|
# # Examples of copying several files to target directory.
|
379
457
|
# FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
380
|
-
# FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', :
|
458
|
+
# FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', noop: true, verbose: true
|
381
459
|
#
|
382
460
|
# # If you want to copy all contents of a directory instead of the
|
383
461
|
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
@@ -412,7 +490,11 @@ module FileUtils
|
|
412
490
|
# If +remove_destination+ is true, this method removes each destination file before copy.
|
413
491
|
#
|
414
492
|
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
|
415
|
-
|
493
|
+
if dereference_root
|
494
|
+
src = File.realpath(src)
|
495
|
+
end
|
496
|
+
|
497
|
+
Entry_.new(src, nil, false).wrap_traverse(proc do |ent|
|
416
498
|
destent = Entry_.new(dest, ent.rel, false)
|
417
499
|
File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path))
|
418
500
|
ent.copy destent.path
|
@@ -449,10 +531,10 @@ module FileUtils
|
|
449
531
|
# disk partition, the file is copied then the original file is removed.
|
450
532
|
#
|
451
533
|
# FileUtils.mv 'badname.rb', 'goodname.rb'
|
452
|
-
# FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :
|
534
|
+
# FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true # no error
|
453
535
|
#
|
454
536
|
# FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
|
455
|
-
# FileUtils.mv Dir.glob('test*.rb'), 'test', :
|
537
|
+
# FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
|
456
538
|
#
|
457
539
|
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
|
458
540
|
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
|
@@ -463,13 +545,12 @@ module FileUtils
|
|
463
545
|
if destent.exist?
|
464
546
|
if destent.directory?
|
465
547
|
raise Errno::EEXIST, d
|
466
|
-
else
|
467
|
-
destent.remove_file if rename_cannot_overwrite_file?
|
468
548
|
end
|
469
549
|
end
|
470
550
|
begin
|
471
551
|
File.rename s, d
|
472
|
-
rescue Errno::EXDEV
|
552
|
+
rescue Errno::EXDEV,
|
553
|
+
Errno::EPERM # move from unencrypted to encrypted dir (ext4)
|
473
554
|
copy_entry s, d, true
|
474
555
|
if secure
|
475
556
|
remove_entry_secure s, force
|
@@ -487,18 +568,13 @@ module FileUtils
|
|
487
568
|
alias move mv
|
488
569
|
module_function :move
|
489
570
|
|
490
|
-
def rename_cannot_overwrite_file? #:nodoc:
|
491
|
-
/emx/ =~ RUBY_PLATFORM
|
492
|
-
end
|
493
|
-
private_module_function :rename_cannot_overwrite_file?
|
494
|
-
|
495
571
|
#
|
496
572
|
# Remove file(s) specified in +list+. This method cannot remove directories.
|
497
573
|
# All StandardErrors are ignored when the :force option is set.
|
498
574
|
#
|
499
575
|
# FileUtils.rm %w( junk.txt dust.txt )
|
500
576
|
# FileUtils.rm Dir.glob('*.so')
|
501
|
-
# FileUtils.rm 'NotExistFile', :
|
577
|
+
# FileUtils.rm 'NotExistFile', force: true # never raises exception
|
502
578
|
#
|
503
579
|
def rm(list, force: nil, noop: nil, verbose: nil)
|
504
580
|
list = fu_list(list)
|
@@ -517,7 +593,7 @@ module FileUtils
|
|
517
593
|
#
|
518
594
|
# Equivalent to
|
519
595
|
#
|
520
|
-
# FileUtils.rm(list, :
|
596
|
+
# FileUtils.rm(list, force: true)
|
521
597
|
#
|
522
598
|
def rm_f(list, noop: nil, verbose: nil)
|
523
599
|
rm list, force: true, noop: noop, verbose: verbose
|
@@ -533,18 +609,18 @@ module FileUtils
|
|
533
609
|
# StandardError when :force option is set.
|
534
610
|
#
|
535
611
|
# FileUtils.rm_r Dir.glob('/tmp/*')
|
536
|
-
# FileUtils.rm_r 'some_dir', :
|
612
|
+
# FileUtils.rm_r 'some_dir', force: true
|
537
613
|
#
|
538
614
|
# WARNING: This method causes local vulnerability
|
539
615
|
# if one of parent directories or removing directory tree are world
|
540
616
|
# writable (including /tmp, whose permission is 1777), and the current
|
541
617
|
# process has strong privilege such as Unix super user (root), and the
|
542
618
|
# system has symbolic link. For secure removing, read the documentation
|
543
|
-
# of
|
544
|
-
# Default is :
|
619
|
+
# of remove_entry_secure carefully, and set :secure option to true.
|
620
|
+
# Default is <tt>secure: false</tt>.
|
545
621
|
#
|
546
|
-
# NOTE: This method calls
|
547
|
-
# See also
|
622
|
+
# NOTE: This method calls remove_entry_secure if :secure option is set.
|
623
|
+
# See also remove_entry_secure.
|
548
624
|
#
|
549
625
|
def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
|
550
626
|
list = fu_list(list)
|
@@ -563,10 +639,10 @@ module FileUtils
|
|
563
639
|
#
|
564
640
|
# Equivalent to
|
565
641
|
#
|
566
|
-
# FileUtils.rm_r(list, :
|
642
|
+
# FileUtils.rm_r(list, force: true)
|
567
643
|
#
|
568
644
|
# WARNING: This method causes local vulnerability.
|
569
|
-
# Read the documentation of
|
645
|
+
# Read the documentation of rm_r first.
|
570
646
|
#
|
571
647
|
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
|
572
648
|
rm_r list, force: true, noop: noop, verbose: verbose, secure: secure
|
@@ -580,7 +656,7 @@ module FileUtils
|
|
580
656
|
# This method removes a file system entry +path+. +path+ shall be a
|
581
657
|
# regular file, a directory, or something. If +path+ is a directory,
|
582
658
|
# remove it recursively. This method is required to avoid TOCTTOU
|
583
|
-
# (time-of-check-to-time-of-use) local security vulnerability of
|
659
|
+
# (time-of-check-to-time-of-use) local security vulnerability of rm_r.
|
584
660
|
# #rm_r causes security hole when:
|
585
661
|
#
|
586
662
|
# * Parent directory is world writable (including /tmp).
|
@@ -603,8 +679,8 @@ module FileUtils
|
|
603
679
|
#
|
604
680
|
# For details of this security vulnerability, see Perl's case:
|
605
681
|
#
|
606
|
-
# *
|
607
|
-
# *
|
682
|
+
# * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
|
683
|
+
# * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
|
608
684
|
#
|
609
685
|
# For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
|
610
686
|
#
|
@@ -628,22 +704,38 @@ module FileUtils
|
|
628
704
|
unless parent_st.sticky?
|
629
705
|
raise ArgumentError, "parent directory is world writable, FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{'%o' % parent_st.mode})"
|
630
706
|
end
|
707
|
+
|
631
708
|
# freeze tree root
|
632
709
|
euid = Process.euid
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
710
|
+
dot_file = fullpath + "/."
|
711
|
+
begin
|
712
|
+
File.open(dot_file) {|f|
|
713
|
+
unless fu_stat_identical_entry?(st, f.stat)
|
714
|
+
# symlink (TOC-to-TOU attack?)
|
715
|
+
File.unlink fullpath
|
716
|
+
return
|
717
|
+
end
|
718
|
+
f.chown euid, -1
|
719
|
+
f.chmod 0700
|
720
|
+
}
|
721
|
+
rescue Errno::EISDIR # JRuby in non-native mode can't open files as dirs
|
722
|
+
File.lstat(dot_file).tap {|fstat|
|
723
|
+
unless fu_stat_identical_entry?(st, fstat)
|
724
|
+
# symlink (TOC-to-TOU attack?)
|
725
|
+
File.unlink fullpath
|
726
|
+
return
|
727
|
+
end
|
728
|
+
File.chown euid, -1, dot_file
|
729
|
+
File.chmod 0700, dot_file
|
730
|
+
}
|
731
|
+
end
|
732
|
+
|
733
|
+
unless fu_stat_identical_entry?(st, File.lstat(fullpath))
|
734
|
+
# TOC-to-TOU attack?
|
735
|
+
File.unlink fullpath
|
736
|
+
return
|
737
|
+
end
|
738
|
+
|
647
739
|
# ---- tree root is frozen ----
|
648
740
|
root = Entry_.new(path)
|
649
741
|
root.preorder_traverse do |ent|
|
@@ -683,7 +775,7 @@ module FileUtils
|
|
683
775
|
# +path+ might be a regular file, a directory, or something.
|
684
776
|
# If +path+ is a directory, remove it recursively.
|
685
777
|
#
|
686
|
-
# See also
|
778
|
+
# See also remove_entry_secure.
|
687
779
|
#
|
688
780
|
def remove_entry(path, force = false)
|
689
781
|
Entry_.new(path).postorder_traverse do |ent|
|
@@ -744,8 +836,15 @@ module FileUtils
|
|
744
836
|
#
|
745
837
|
def compare_stream(a, b)
|
746
838
|
bsize = fu_stream_blksize(a, b)
|
747
|
-
|
748
|
-
|
839
|
+
|
840
|
+
if RUBY_VERSION > "2.4"
|
841
|
+
sa = String.new(capacity: bsize)
|
842
|
+
sb = String.new(capacity: bsize)
|
843
|
+
else
|
844
|
+
sa = String.new
|
845
|
+
sb = String.new
|
846
|
+
end
|
847
|
+
|
749
848
|
begin
|
750
849
|
a.read(bsize, sa)
|
751
850
|
b.read(bsize, sb)
|
@@ -760,8 +859,8 @@ module FileUtils
|
|
760
859
|
# mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
|
761
860
|
# This method removes destination before copy.
|
762
861
|
#
|
763
|
-
# FileUtils.install 'ruby', '/usr/local/bin/ruby', :
|
764
|
-
# FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :
|
862
|
+
# FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
|
863
|
+
# FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
|
765
864
|
#
|
766
865
|
def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
|
767
866
|
noop: nil, verbose: nil)
|
@@ -821,11 +920,8 @@ module FileUtils
|
|
821
920
|
private_module_function :apply_mask
|
822
921
|
|
823
922
|
def symbolic_modes_to_i(mode_sym, path) #:nodoc:
|
824
|
-
|
825
|
-
|
826
|
-
else
|
827
|
-
File.stat(path).mode
|
828
|
-
end
|
923
|
+
path = File.stat(path) unless File::Stat === path
|
924
|
+
mode = path.mode
|
829
925
|
mode_sym.split(/,/).inject(mode & 07777) do |current_mode, clause|
|
830
926
|
target, *actions = clause.split(/([=+-])/)
|
831
927
|
raise ArgumentError, "invalid file mode: #{mode_sym}" if actions.empty?
|
@@ -842,7 +938,7 @@ module FileUtils
|
|
842
938
|
when "x"
|
843
939
|
mask | 0111
|
844
940
|
when "X"
|
845
|
-
if
|
941
|
+
if path.directory?
|
846
942
|
mask | 0111
|
847
943
|
else
|
848
944
|
mask
|
@@ -891,12 +987,12 @@ module FileUtils
|
|
891
987
|
# Absolute mode is
|
892
988
|
# FileUtils.chmod 0755, 'somecommand'
|
893
989
|
# FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
|
894
|
-
# FileUtils.chmod 0755, '/usr/bin/ruby', :
|
990
|
+
# FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
|
895
991
|
#
|
896
992
|
# Symbolic mode is
|
897
993
|
# FileUtils.chmod "u=wrx,go=rx", 'somecommand'
|
898
994
|
# FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
|
899
|
-
# FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :
|
995
|
+
# FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
|
900
996
|
#
|
901
997
|
# "a" :: is user, group, other mask.
|
902
998
|
# "u" :: is user's mask.
|
@@ -956,7 +1052,7 @@ module FileUtils
|
|
956
1052
|
# the attribute.
|
957
1053
|
#
|
958
1054
|
# FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
|
959
|
-
# FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :
|
1055
|
+
# FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
|
960
1056
|
#
|
961
1057
|
def chown(user, group, list, noop: nil, verbose: nil)
|
962
1058
|
list = fu_list(list)
|
@@ -980,7 +1076,7 @@ module FileUtils
|
|
980
1076
|
# method does not change the attribute.
|
981
1077
|
#
|
982
1078
|
# FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
|
983
|
-
# FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :
|
1079
|
+
# FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
|
984
1080
|
#
|
985
1081
|
def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
|
986
1082
|
list = fu_list(list)
|
@@ -1003,11 +1099,6 @@ module FileUtils
|
|
1003
1099
|
end
|
1004
1100
|
module_function :chown_R
|
1005
1101
|
|
1006
|
-
begin
|
1007
|
-
require 'etc'
|
1008
|
-
rescue LoadError # rescue LoadError for miniruby
|
1009
|
-
end
|
1010
|
-
|
1011
1102
|
def fu_get_uid(user) #:nodoc:
|
1012
1103
|
return nil unless user
|
1013
1104
|
case user
|
@@ -1016,6 +1107,7 @@ module FileUtils
|
|
1016
1107
|
when /\A\d+\z/
|
1017
1108
|
user.to_i
|
1018
1109
|
else
|
1110
|
+
require 'etc'
|
1019
1111
|
Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
|
1020
1112
|
end
|
1021
1113
|
end
|
@@ -1029,6 +1121,7 @@ module FileUtils
|
|
1029
1121
|
when /\A\d+\z/
|
1030
1122
|
group.to_i
|
1031
1123
|
else
|
1124
|
+
require 'etc'
|
1032
1125
|
Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
|
1033
1126
|
end
|
1034
1127
|
end
|
@@ -1069,8 +1162,11 @@ module FileUtils
|
|
1069
1162
|
module StreamUtils_
|
1070
1163
|
private
|
1071
1164
|
|
1072
|
-
|
1073
|
-
|
1165
|
+
case (defined?(::RbConfig) ? ::RbConfig::CONFIG['host_os'] : ::RUBY_PLATFORM)
|
1166
|
+
when /mswin|mingw/
|
1167
|
+
def fu_windows?; true end
|
1168
|
+
else
|
1169
|
+
def fu_windows?; false end
|
1074
1170
|
end
|
1075
1171
|
|
1076
1172
|
def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
|
@@ -1194,10 +1290,17 @@ module FileUtils
|
|
1194
1290
|
|
1195
1291
|
def entries
|
1196
1292
|
opts = {}
|
1197
|
-
opts[:encoding] = ::Encoding::UTF_8
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1293
|
+
opts[:encoding] = fu_windows? ? ::Encoding::UTF_8 : path.encoding
|
1294
|
+
|
1295
|
+
files = if Dir.respond_to?(:children)
|
1296
|
+
Dir.children(path, **opts)
|
1297
|
+
else
|
1298
|
+
Dir.entries(path(), **opts)
|
1299
|
+
.reject {|n| n == '.' or n == '..' }
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
untaint = RUBY_VERSION < '2.7'
|
1303
|
+
files.map {|n| Entry_.new(prefix(), join(rel(), untaint ? n.untaint : n)) }
|
1201
1304
|
end
|
1202
1305
|
|
1203
1306
|
def stat
|
@@ -1242,6 +1345,7 @@ module FileUtils
|
|
1242
1345
|
else
|
1243
1346
|
File.chmod mode, path()
|
1244
1347
|
end
|
1348
|
+
rescue Errno::EOPNOTSUPP
|
1245
1349
|
end
|
1246
1350
|
|
1247
1351
|
def chown(uid, gid)
|
@@ -1252,6 +1356,22 @@ module FileUtils
|
|
1252
1356
|
end
|
1253
1357
|
end
|
1254
1358
|
|
1359
|
+
def link(dest)
|
1360
|
+
case
|
1361
|
+
when directory?
|
1362
|
+
if !File.exist?(dest) and descendant_directory?(dest, path)
|
1363
|
+
raise ArgumentError, "cannot link directory %s to itself %s" % [path, dest]
|
1364
|
+
end
|
1365
|
+
begin
|
1366
|
+
Dir.mkdir dest
|
1367
|
+
rescue
|
1368
|
+
raise unless File.directory?(dest)
|
1369
|
+
end
|
1370
|
+
else
|
1371
|
+
File.link path(), dest
|
1372
|
+
end
|
1373
|
+
end
|
1374
|
+
|
1255
1375
|
def copy(dest)
|
1256
1376
|
lstat
|
1257
1377
|
case
|
@@ -1268,18 +1388,21 @@ module FileUtils
|
|
1268
1388
|
end
|
1269
1389
|
when symlink?
|
1270
1390
|
File.symlink File.readlink(path()), dest
|
1271
|
-
when chardev?
|
1272
|
-
raise "cannot handle device file"
|
1273
|
-
mknod dest, ?c, 0666, lstat().rdev
|
1274
|
-
when blockdev?
|
1275
|
-
raise "cannot handle device file" unless File.respond_to?(:mknod)
|
1276
|
-
mknod dest, ?b, 0666, lstat().rdev
|
1391
|
+
when chardev?, blockdev?
|
1392
|
+
raise "cannot handle device file"
|
1277
1393
|
when socket?
|
1278
|
-
|
1279
|
-
|
1394
|
+
begin
|
1395
|
+
require 'socket'
|
1396
|
+
rescue LoadError
|
1397
|
+
raise "cannot handle socket"
|
1398
|
+
else
|
1399
|
+
raise "cannot handle socket" unless defined?(UNIXServer)
|
1400
|
+
end
|
1401
|
+
UNIXServer.new(dest).close
|
1402
|
+
File.chmod lstat().mode, dest
|
1280
1403
|
when pipe?
|
1281
1404
|
raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
|
1282
|
-
mkfifo dest,
|
1405
|
+
File.mkfifo dest, lstat().mode
|
1283
1406
|
when door?
|
1284
1407
|
raise "cannot handle door: #{path()}"
|
1285
1408
|
else
|
@@ -1317,7 +1440,7 @@ module FileUtils
|
|
1317
1440
|
if st.symlink?
|
1318
1441
|
begin
|
1319
1442
|
File.lchmod mode, path
|
1320
|
-
rescue NotImplementedError
|
1443
|
+
rescue NotImplementedError, Errno::EOPNOTSUPP
|
1321
1444
|
end
|
1322
1445
|
else
|
1323
1446
|
File.chmod mode, path
|
@@ -1398,14 +1521,14 @@ module FileUtils
|
|
1398
1521
|
|
1399
1522
|
private
|
1400
1523
|
|
1401
|
-
|
1524
|
+
@@fileutils_rb_have_lchmod = nil
|
1402
1525
|
|
1403
1526
|
def have_lchmod?
|
1404
1527
|
# This is not MT-safe, but it does not matter.
|
1405
|
-
if
|
1406
|
-
|
1528
|
+
if @@fileutils_rb_have_lchmod == nil
|
1529
|
+
@@fileutils_rb_have_lchmod = check_have_lchmod?
|
1407
1530
|
end
|
1408
|
-
|
1531
|
+
@@fileutils_rb_have_lchmod
|
1409
1532
|
end
|
1410
1533
|
|
1411
1534
|
def check_have_lchmod?
|
@@ -1416,14 +1539,14 @@ module FileUtils
|
|
1416
1539
|
return false
|
1417
1540
|
end
|
1418
1541
|
|
1419
|
-
|
1542
|
+
@@fileutils_rb_have_lchown = nil
|
1420
1543
|
|
1421
1544
|
def have_lchown?
|
1422
1545
|
# This is not MT-safe, but it does not matter.
|
1423
|
-
if
|
1424
|
-
|
1546
|
+
if @@fileutils_rb_have_lchown == nil
|
1547
|
+
@@fileutils_rb_have_lchown = check_have_lchown?
|
1425
1548
|
end
|
1426
|
-
|
1549
|
+
@@fileutils_rb_have_lchown
|
1427
1550
|
end
|
1428
1551
|
|
1429
1552
|
def check_have_lchown?
|
@@ -1437,7 +1560,15 @@ module FileUtils
|
|
1437
1560
|
def join(dir, base)
|
1438
1561
|
return File.path(dir) if not base or base == '.'
|
1439
1562
|
return File.path(base) if not dir or dir == '.'
|
1440
|
-
|
1563
|
+
begin
|
1564
|
+
File.join(dir, base)
|
1565
|
+
rescue EncodingError
|
1566
|
+
if fu_windows?
|
1567
|
+
File.join(dir.encode(::Encoding::UTF_8), base.encode(::Encoding::UTF_8))
|
1568
|
+
else
|
1569
|
+
raise
|
1570
|
+
end
|
1571
|
+
end
|
1441
1572
|
end
|
1442
1573
|
|
1443
1574
|
if File::ALT_SEPARATOR
|
@@ -1445,10 +1576,13 @@ module FileUtils
|
|
1445
1576
|
else
|
1446
1577
|
DIRECTORY_TERM = "(?=/|\\z)"
|
1447
1578
|
end
|
1448
|
-
SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : ""
|
1449
1579
|
|
1450
1580
|
def descendant_directory?(descendant, ascendant)
|
1451
|
-
|
1581
|
+
if File::FNM_SYSCASE.nonzero?
|
1582
|
+
File.expand_path(File.dirname(descendant)).casecmp(File.expand_path(ascendant)) == 0
|
1583
|
+
else
|
1584
|
+
File.expand_path(File.dirname(descendant)) == File.expand_path(ascendant)
|
1585
|
+
end
|
1452
1586
|
end
|
1453
1587
|
end # class Entry_
|
1454
1588
|
|
@@ -1487,13 +1621,13 @@ module FileUtils
|
|
1487
1621
|
end
|
1488
1622
|
private_module_function :fu_same?
|
1489
1623
|
|
1490
|
-
@fileutils_output = $stderr
|
1491
|
-
@fileutils_label = ''
|
1492
|
-
|
1493
1624
|
def fu_output_message(msg) #:nodoc:
|
1494
|
-
@fileutils_output
|
1495
|
-
|
1496
|
-
|
1625
|
+
output = @fileutils_output if defined?(@fileutils_output)
|
1626
|
+
output ||= $stdout
|
1627
|
+
if defined?(@fileutils_label)
|
1628
|
+
msg = @fileutils_label + msg
|
1629
|
+
end
|
1630
|
+
output.puts msg
|
1497
1631
|
end
|
1498
1632
|
private_module_function :fu_output_message
|
1499
1633
|
|
@@ -1504,8 +1638,11 @@ module FileUtils
|
|
1504
1638
|
tbl
|
1505
1639
|
}
|
1506
1640
|
|
1641
|
+
public
|
1642
|
+
|
1507
1643
|
#
|
1508
|
-
# Returns an Array of
|
1644
|
+
# Returns an Array of names of high-level methods that accept any keyword
|
1645
|
+
# arguments.
|
1509
1646
|
#
|
1510
1647
|
# p FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
|
1511
1648
|
#
|
@@ -1544,7 +1681,7 @@ module FileUtils
|
|
1544
1681
|
end
|
1545
1682
|
|
1546
1683
|
#
|
1547
|
-
# Returns an Array of
|
1684
|
+
# Returns an Array of methods names which have the option +opt+.
|
1548
1685
|
#
|
1549
1686
|
# p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
|
1550
1687
|
#
|
@@ -1552,14 +1689,16 @@ module FileUtils
|
|
1552
1689
|
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
|
1553
1690
|
end
|
1554
1691
|
|
1555
|
-
|
1556
|
-
|
1692
|
+
private
|
1693
|
+
|
1694
|
+
LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern) # :nodoc:
|
1695
|
+
module LowMethods # :nodoc: internal use only
|
1557
1696
|
private
|
1558
1697
|
def _do_nothing(*)end
|
1559
1698
|
::FileUtils::LOW_METHODS.map {|name| alias_method name, :_do_nothing}
|
1560
1699
|
end
|
1561
1700
|
|
1562
|
-
METHODS = singleton_methods() - [:private_module_function,
|
1701
|
+
METHODS = singleton_methods() - [:private_module_function, # :nodoc:
|
1563
1702
|
:commands, :options, :have_option?, :options_of, :collect_method]
|
1564
1703
|
|
1565
1704
|
#
|
@@ -1569,8 +1708,6 @@ module FileUtils
|
|
1569
1708
|
#
|
1570
1709
|
module Verbose
|
1571
1710
|
include FileUtils
|
1572
|
-
@fileutils_output = $stderr
|
1573
|
-
@fileutils_label = ''
|
1574
1711
|
names = ::FileUtils.collect_method(:verbose)
|
1575
1712
|
names.each do |name|
|
1576
1713
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
@@ -1594,8 +1731,6 @@ module FileUtils
|
|
1594
1731
|
module NoWrite
|
1595
1732
|
include FileUtils
|
1596
1733
|
include LowMethods
|
1597
|
-
@fileutils_output = $stderr
|
1598
|
-
@fileutils_label = ''
|
1599
1734
|
names = ::FileUtils.collect_method(:noop)
|
1600
1735
|
names.each do |name|
|
1601
1736
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
@@ -1620,8 +1755,6 @@ module FileUtils
|
|
1620
1755
|
module DryRun
|
1621
1756
|
include FileUtils
|
1622
1757
|
include LowMethods
|
1623
|
-
@fileutils_output = $stderr
|
1624
|
-
@fileutils_label = ''
|
1625
1758
|
names = ::FileUtils.collect_method(:noop)
|
1626
1759
|
names.each do |name|
|
1627
1760
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
metadata
CHANGED
@@ -1,52 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2020-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Several file utility methods for copying, moving, removing, etc.
|
28
14
|
email:
|
29
|
-
-
|
15
|
+
-
|
30
16
|
executables: []
|
31
17
|
extensions: []
|
32
18
|
extra_rdoc_files: []
|
33
19
|
files:
|
34
|
-
- ".gitignore"
|
35
|
-
- ".travis.yml"
|
36
|
-
- Gemfile
|
37
20
|
- LICENSE.txt
|
38
21
|
- README.md
|
39
22
|
- Rakefile
|
40
|
-
- bin/console
|
41
|
-
- bin/setup
|
42
23
|
- fileutils.gemspec
|
43
24
|
- lib/fileutils.rb
|
44
25
|
homepage: https://github.com/ruby/fileutils
|
45
26
|
licenses:
|
27
|
+
- Ruby
|
46
28
|
- BSD-2-Clause
|
47
29
|
metadata:
|
48
30
|
source_code_uri: https://github.com/ruby/fileutils
|
49
|
-
post_install_message:
|
31
|
+
post_install_message:
|
50
32
|
rdoc_options: []
|
51
33
|
require_paths:
|
52
34
|
- lib
|
@@ -54,16 +36,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
36
|
requirements:
|
55
37
|
- - ">="
|
56
38
|
- !ruby/object:Gem::Version
|
57
|
-
version: 2.
|
39
|
+
version: 2.3.0
|
58
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
41
|
requirements:
|
60
42
|
- - ">="
|
61
43
|
- !ruby/object:Gem::Version
|
62
44
|
version: '0'
|
63
45
|
requirements: []
|
64
|
-
|
65
|
-
|
66
|
-
signing_key:
|
46
|
+
rubygems_version: 3.2.2
|
47
|
+
signing_key:
|
67
48
|
specification_version: 4
|
68
49
|
summary: Several file utility methods for copying, moving, removing, etc.
|
69
50
|
test_files: []
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "fileutils"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|