fileutils 1.2.0 → 1.3.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/fileutils.gemspec +0 -2
- data/lib/fileutils.rb +132 -109
- data/lib/fileutils/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34d7f0ea2d7241dc23eba2ec5d7be548d2dab3edb9082e94fc7766b70ce8dcd2
|
4
|
+
data.tar.gz: c0a41797554a3a763ff7d7ac7b6f1f149d50bcefe0ddef959b98a1384f40ba93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78deb94048b06e1c7d3215f3bc796447caf909c047f14f137a367e907b4f4fb5655c5ceb211390d5ead7f9e8710b6daf33d262ff31a5b3f186bb2d40f2f4900f
|
7
|
+
data.tar.gz: f57997f8e332a07d3ab01db4e31ae2e196179a1fb35e6ebf1d123f156e96c5ab415f8f408690767216194a65d92b2d7f77adce83719ffe40d8eeada4cfbb8c4b
|
data/README.md
CHANGED
data/fileutils.gemspec
CHANGED
data/lib/fileutils.rb
CHANGED
@@ -6,7 +6,7 @@ rescue LoadError
|
|
6
6
|
# for make mjit-headers
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
require_relative "fileutils/version"
|
10
10
|
|
11
11
|
#
|
12
12
|
# = fileutils.rb
|
@@ -24,46 +24,56 @@ require "fileutils/version"
|
|
24
24
|
#
|
25
25
|
# require 'fileutils'
|
26
26
|
#
|
27
|
-
# FileUtils.cd(dir, options)
|
28
|
-
# FileUtils.cd(dir, options) {|dir| block }
|
27
|
+
# FileUtils.cd(dir, **options)
|
28
|
+
# FileUtils.cd(dir, **options) {|dir| block }
|
29
29
|
# FileUtils.pwd()
|
30
|
-
# FileUtils.mkdir(dir, options)
|
31
|
-
# FileUtils.mkdir(list, options)
|
32
|
-
# FileUtils.mkdir_p(dir, options)
|
33
|
-
# FileUtils.mkdir_p(list, options)
|
34
|
-
# FileUtils.rmdir(dir, options)
|
35
|
-
# FileUtils.rmdir(list, options)
|
36
|
-
# FileUtils.ln(target, link, options)
|
37
|
-
# FileUtils.ln(targets, dir, options)
|
38
|
-
# FileUtils.ln_s(target, link, options)
|
39
|
-
# FileUtils.ln_s(targets, dir, options)
|
40
|
-
# FileUtils.ln_sf(target, link, options)
|
41
|
-
# FileUtils.cp(src, dest, options)
|
42
|
-
# FileUtils.cp(list, dir, options)
|
43
|
-
# FileUtils.cp_r(src, dest, options)
|
44
|
-
# FileUtils.cp_r(list, dir, options)
|
45
|
-
# FileUtils.mv(src, dest, options)
|
46
|
-
# FileUtils.mv(list, dir, options)
|
47
|
-
# FileUtils.rm(list, options)
|
48
|
-
# FileUtils.rm_r(list, options)
|
49
|
-
# FileUtils.rm_rf(list, options)
|
50
|
-
# FileUtils.install(src, dest, options)
|
51
|
-
# FileUtils.chmod(mode, list, options)
|
52
|
-
# FileUtils.chmod_R(mode, list, options)
|
53
|
-
# FileUtils.chown(user, group, list, options)
|
54
|
-
# FileUtils.chown_R(user, group, list, options)
|
55
|
-
# FileUtils.touch(list, options)
|
30
|
+
# FileUtils.mkdir(dir, **options)
|
31
|
+
# FileUtils.mkdir(list, **options)
|
32
|
+
# FileUtils.mkdir_p(dir, **options)
|
33
|
+
# FileUtils.mkdir_p(list, **options)
|
34
|
+
# FileUtils.rmdir(dir, **options)
|
35
|
+
# FileUtils.rmdir(list, **options)
|
36
|
+
# FileUtils.ln(target, link, **options)
|
37
|
+
# FileUtils.ln(targets, dir, **options)
|
38
|
+
# FileUtils.ln_s(target, link, **options)
|
39
|
+
# FileUtils.ln_s(targets, dir, **options)
|
40
|
+
# FileUtils.ln_sf(target, link, **options)
|
41
|
+
# FileUtils.cp(src, dest, **options)
|
42
|
+
# FileUtils.cp(list, dir, **options)
|
43
|
+
# FileUtils.cp_r(src, dest, **options)
|
44
|
+
# FileUtils.cp_r(list, dir, **options)
|
45
|
+
# FileUtils.mv(src, dest, **options)
|
46
|
+
# FileUtils.mv(list, dir, **options)
|
47
|
+
# FileUtils.rm(list, **options)
|
48
|
+
# FileUtils.rm_r(list, **options)
|
49
|
+
# FileUtils.rm_rf(list, **options)
|
50
|
+
# FileUtils.install(src, dest, **options)
|
51
|
+
# FileUtils.chmod(mode, list, **options)
|
52
|
+
# FileUtils.chmod_R(mode, list, **options)
|
53
|
+
# FileUtils.chown(user, group, list, **options)
|
54
|
+
# FileUtils.chown_R(user, group, list, **options)
|
55
|
+
# FileUtils.touch(list, **options)
|
56
56
|
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# <tt>:
|
60
|
-
#
|
57
|
+
# Possible <tt>options</tt> are:
|
58
|
+
#
|
59
|
+
# <tt>:force</tt> :: forced operation (rewrite files if exist, remove
|
60
|
+
# directories if not empty, etc.);
|
61
|
+
# <tt>:verbose</tt> :: print command to be run, in bash syntax, before
|
62
|
+
# performing it;
|
63
|
+
# <tt>:preserve</tt> :: preserve object's group, user and modification
|
64
|
+
# time on copying;
|
65
|
+
# <tt>:noop</tt> :: no changes are made (usable in combination with
|
66
|
+
# <tt>:verbose</tt> which will print the command to run)
|
67
|
+
#
|
68
|
+
# Each method documents the options that it honours. See also ::commands,
|
69
|
+
# ::options and ::options_of methods to introspect which command have which
|
70
|
+
# options.
|
61
71
|
#
|
62
72
|
# All methods that have the concept of a "source" file or directory can take
|
63
73
|
# either one file or a list of files in that argument. See the method
|
64
74
|
# documentation for examples.
|
65
75
|
#
|
66
|
-
# There are some `low level' methods, which do not accept
|
76
|
+
# There are some `low level' methods, which do not accept keyword arguments:
|
67
77
|
#
|
68
78
|
# FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
|
69
79
|
# FileUtils.copy_file(src, dest, preserve = false, dereference = true)
|
@@ -119,7 +129,7 @@ module FileUtils
|
|
119
129
|
#
|
120
130
|
# FileUtils.cd('/') # change directory
|
121
131
|
#
|
122
|
-
# FileUtils.cd('/', :
|
132
|
+
# FileUtils.cd('/', verbose: true) # change directory and report it
|
123
133
|
#
|
124
134
|
# FileUtils.cd('/') do # change directory
|
125
135
|
# # ... # do something
|
@@ -164,9 +174,9 @@ module FileUtils
|
|
164
174
|
# Creates one or more directories.
|
165
175
|
#
|
166
176
|
# FileUtils.mkdir 'test'
|
167
|
-
# FileUtils.mkdir %w(
|
168
|
-
# FileUtils.mkdir 'notexist', :
|
169
|
-
# FileUtils.mkdir 'tmp', :
|
177
|
+
# FileUtils.mkdir %w(tmp data)
|
178
|
+
# FileUtils.mkdir 'notexist', noop: true # Does not really create.
|
179
|
+
# FileUtils.mkdir 'tmp', mode: 0700
|
170
180
|
#
|
171
181
|
def mkdir(list, mode: nil, noop: nil, verbose: nil)
|
172
182
|
list = fu_list(list)
|
@@ -185,7 +195,7 @@ module FileUtils
|
|
185
195
|
#
|
186
196
|
# FileUtils.mkdir_p '/usr/local/lib/ruby'
|
187
197
|
#
|
188
|
-
# causes to make following directories, if
|
198
|
+
# causes to make following directories, if they do not exist.
|
189
199
|
#
|
190
200
|
# * /usr
|
191
201
|
# * /usr/local
|
@@ -249,7 +259,7 @@ module FileUtils
|
|
249
259
|
# FileUtils.rmdir 'somedir'
|
250
260
|
# FileUtils.rmdir %w(somedir anydir otherdir)
|
251
261
|
# # Does not really remove directory; outputs message.
|
252
|
-
# FileUtils.rmdir 'somedir', :
|
262
|
+
# FileUtils.rmdir 'somedir', verbose: true, noop: true
|
253
263
|
#
|
254
264
|
def rmdir(list, parents: nil, noop: nil, verbose: nil)
|
255
265
|
list = fu_list(list)
|
@@ -278,7 +288,7 @@ module FileUtils
|
|
278
288
|
#
|
279
289
|
# In the first form, creates a hard link +link+ which points to +target+.
|
280
290
|
# If +link+ already exists, raises Errno::EEXIST.
|
281
|
-
# But if the
|
291
|
+
# But if the +force+ option is set, overwrites +link+.
|
282
292
|
#
|
283
293
|
# FileUtils.ln 'gcc', 'cc', verbose: true
|
284
294
|
# FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
|
@@ -304,9 +314,6 @@ module FileUtils
|
|
304
314
|
alias link ln
|
305
315
|
module_function :link
|
306
316
|
|
307
|
-
#
|
308
|
-
# :call-seq:
|
309
|
-
# FileUtils.cp_lr(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false)
|
310
317
|
#
|
311
318
|
# Hard link +src+ to +dest+. If +src+ is a directory, this method links
|
312
319
|
# all its contents recursively. If +dest+ is a directory, links
|
@@ -314,13 +321,16 @@ module FileUtils
|
|
314
321
|
#
|
315
322
|
# +src+ can be a list of files.
|
316
323
|
#
|
317
|
-
#
|
318
|
-
#
|
324
|
+
# If +dereference_root+ is true, this method dereference tree root.
|
325
|
+
#
|
326
|
+
# If +remove_destination+ is true, this method removes each destination file before copy.
|
327
|
+
#
|
328
|
+
# FileUtils.rm_r site_ruby + '/mylib', force: true
|
319
329
|
# FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
|
320
330
|
#
|
321
331
|
# # Examples of linking several files to target directory.
|
322
332
|
# FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
323
|
-
# FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', :
|
333
|
+
# FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
|
324
334
|
#
|
325
335
|
# # If you want to link all contents of a directory instead of the
|
326
336
|
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
@@ -345,7 +355,7 @@ module FileUtils
|
|
345
355
|
#
|
346
356
|
# In the first form, creates a symbolic link +link+ which points to +target+.
|
347
357
|
# If +link+ already exists, raises Errno::EEXIST.
|
348
|
-
# But if the
|
358
|
+
# But if the <tt>force</tt> option is set, overwrites +link+.
|
349
359
|
#
|
350
360
|
# FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
|
351
361
|
# FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
|
@@ -411,7 +421,7 @@ module FileUtils
|
|
411
421
|
#
|
412
422
|
# FileUtils.cp 'eval.c', 'eval.c.org'
|
413
423
|
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
|
414
|
-
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :
|
424
|
+
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', verbose: true
|
415
425
|
# FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
|
416
426
|
#
|
417
427
|
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
|
@@ -433,13 +443,17 @@ module FileUtils
|
|
433
443
|
#
|
434
444
|
# +src+ can be a list of files.
|
435
445
|
#
|
446
|
+
# If +dereference_root+ is true, this method dereference tree root.
|
447
|
+
#
|
448
|
+
# If +remove_destination+ is true, this method removes each destination file before copy.
|
449
|
+
#
|
436
450
|
# # Installing Ruby library "mylib" under the site_ruby
|
437
|
-
# FileUtils.rm_r site_ruby + '/mylib', :
|
451
|
+
# FileUtils.rm_r site_ruby + '/mylib', force: true
|
438
452
|
# FileUtils.cp_r 'lib/', site_ruby + '/mylib'
|
439
453
|
#
|
440
454
|
# # Examples of copying several files to target directory.
|
441
455
|
# FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
442
|
-
# FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', :
|
456
|
+
# FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', noop: true, verbose: true
|
443
457
|
#
|
444
458
|
# # If you want to copy all contents of a directory instead of the
|
445
459
|
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
@@ -474,7 +488,11 @@ module FileUtils
|
|
474
488
|
# If +remove_destination+ is true, this method removes each destination file before copy.
|
475
489
|
#
|
476
490
|
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
|
477
|
-
|
491
|
+
if dereference_root
|
492
|
+
src = File.realpath(src)
|
493
|
+
end
|
494
|
+
|
495
|
+
Entry_.new(src, nil, false).wrap_traverse(proc do |ent|
|
478
496
|
destent = Entry_.new(dest, ent.rel, false)
|
479
497
|
File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path))
|
480
498
|
ent.copy destent.path
|
@@ -511,10 +529,10 @@ module FileUtils
|
|
511
529
|
# disk partition, the file is copied then the original file is removed.
|
512
530
|
#
|
513
531
|
# FileUtils.mv 'badname.rb', 'goodname.rb'
|
514
|
-
# FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :
|
532
|
+
# FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true # no error
|
515
533
|
#
|
516
534
|
# FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
|
517
|
-
# FileUtils.mv Dir.glob('test*.rb'), 'test', :
|
535
|
+
# FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
|
518
536
|
#
|
519
537
|
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
|
520
538
|
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
|
@@ -554,7 +572,7 @@ module FileUtils
|
|
554
572
|
#
|
555
573
|
# FileUtils.rm %w( junk.txt dust.txt )
|
556
574
|
# FileUtils.rm Dir.glob('*.so')
|
557
|
-
# FileUtils.rm 'NotExistFile', :
|
575
|
+
# FileUtils.rm 'NotExistFile', force: true # never raises exception
|
558
576
|
#
|
559
577
|
def rm(list, force: nil, noop: nil, verbose: nil)
|
560
578
|
list = fu_list(list)
|
@@ -573,7 +591,7 @@ module FileUtils
|
|
573
591
|
#
|
574
592
|
# Equivalent to
|
575
593
|
#
|
576
|
-
# FileUtils.rm(list, :
|
594
|
+
# FileUtils.rm(list, force: true)
|
577
595
|
#
|
578
596
|
def rm_f(list, noop: nil, verbose: nil)
|
579
597
|
rm list, force: true, noop: noop, verbose: verbose
|
@@ -589,18 +607,18 @@ module FileUtils
|
|
589
607
|
# StandardError when :force option is set.
|
590
608
|
#
|
591
609
|
# FileUtils.rm_r Dir.glob('/tmp/*')
|
592
|
-
# FileUtils.rm_r 'some_dir', :
|
610
|
+
# FileUtils.rm_r 'some_dir', force: true
|
593
611
|
#
|
594
612
|
# WARNING: This method causes local vulnerability
|
595
613
|
# if one of parent directories or removing directory tree are world
|
596
614
|
# writable (including /tmp, whose permission is 1777), and the current
|
597
615
|
# process has strong privilege such as Unix super user (root), and the
|
598
616
|
# system has symbolic link. For secure removing, read the documentation
|
599
|
-
# of
|
600
|
-
# Default is :
|
617
|
+
# of remove_entry_secure carefully, and set :secure option to true.
|
618
|
+
# Default is <tt>secure: false</tt>.
|
601
619
|
#
|
602
|
-
# NOTE: This method calls
|
603
|
-
# See also
|
620
|
+
# NOTE: This method calls remove_entry_secure if :secure option is set.
|
621
|
+
# See also remove_entry_secure.
|
604
622
|
#
|
605
623
|
def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
|
606
624
|
list = fu_list(list)
|
@@ -619,10 +637,10 @@ module FileUtils
|
|
619
637
|
#
|
620
638
|
# Equivalent to
|
621
639
|
#
|
622
|
-
# FileUtils.rm_r(list, :
|
640
|
+
# FileUtils.rm_r(list, force: true)
|
623
641
|
#
|
624
642
|
# WARNING: This method causes local vulnerability.
|
625
|
-
# Read the documentation of
|
643
|
+
# Read the documentation of rm_r first.
|
626
644
|
#
|
627
645
|
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
|
628
646
|
rm_r list, force: true, noop: noop, verbose: verbose, secure: secure
|
@@ -636,7 +654,7 @@ module FileUtils
|
|
636
654
|
# This method removes a file system entry +path+. +path+ shall be a
|
637
655
|
# regular file, a directory, or something. If +path+ is a directory,
|
638
656
|
# remove it recursively. This method is required to avoid TOCTTOU
|
639
|
-
# (time-of-check-to-time-of-use) local security vulnerability of
|
657
|
+
# (time-of-check-to-time-of-use) local security vulnerability of rm_r.
|
640
658
|
# #rm_r causes security hole when:
|
641
659
|
#
|
642
660
|
# * Parent directory is world writable (including /tmp).
|
@@ -755,7 +773,7 @@ module FileUtils
|
|
755
773
|
# +path+ might be a regular file, a directory, or something.
|
756
774
|
# If +path+ is a directory, remove it recursively.
|
757
775
|
#
|
758
|
-
# See also
|
776
|
+
# See also remove_entry_secure.
|
759
777
|
#
|
760
778
|
def remove_entry(path, force = false)
|
761
779
|
Entry_.new(path).postorder_traverse do |ent|
|
@@ -839,8 +857,8 @@ module FileUtils
|
|
839
857
|
# mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
|
840
858
|
# This method removes destination before copy.
|
841
859
|
#
|
842
|
-
# FileUtils.install 'ruby', '/usr/local/bin/ruby', :
|
843
|
-
# FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :
|
860
|
+
# FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
|
861
|
+
# FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
|
844
862
|
#
|
845
863
|
def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
|
846
864
|
noop: nil, verbose: nil)
|
@@ -970,12 +988,12 @@ module FileUtils
|
|
970
988
|
# Absolute mode is
|
971
989
|
# FileUtils.chmod 0755, 'somecommand'
|
972
990
|
# FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
|
973
|
-
# FileUtils.chmod 0755, '/usr/bin/ruby', :
|
991
|
+
# FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
|
974
992
|
#
|
975
993
|
# Symbolic mode is
|
976
994
|
# FileUtils.chmod "u=wrx,go=rx", 'somecommand'
|
977
995
|
# FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
|
978
|
-
# FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :
|
996
|
+
# FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
|
979
997
|
#
|
980
998
|
# "a" :: is user, group, other mask.
|
981
999
|
# "u" :: is user's mask.
|
@@ -1035,7 +1053,7 @@ module FileUtils
|
|
1035
1053
|
# the attribute.
|
1036
1054
|
#
|
1037
1055
|
# FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
|
1038
|
-
# FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :
|
1056
|
+
# FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
|
1039
1057
|
#
|
1040
1058
|
def chown(user, group, list, noop: nil, verbose: nil)
|
1041
1059
|
list = fu_list(list)
|
@@ -1059,7 +1077,7 @@ module FileUtils
|
|
1059
1077
|
# method does not change the attribute.
|
1060
1078
|
#
|
1061
1079
|
# FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
|
1062
|
-
# FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :
|
1080
|
+
# FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
|
1063
1081
|
#
|
1064
1082
|
def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
|
1065
1083
|
list = fu_list(list)
|
@@ -1276,9 +1294,9 @@ module FileUtils
|
|
1276
1294
|
opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
|
1277
1295
|
|
1278
1296
|
files = if Dir.respond_to?(:children)
|
1279
|
-
Dir.children(path, opts)
|
1297
|
+
Dir.children(path, **opts)
|
1280
1298
|
else
|
1281
|
-
Dir.entries(path(), opts)
|
1299
|
+
Dir.entries(path(), **opts)
|
1282
1300
|
.reject {|n| n == '.' or n == '..' }
|
1283
1301
|
end
|
1284
1302
|
|
@@ -1369,18 +1387,21 @@ module FileUtils
|
|
1369
1387
|
end
|
1370
1388
|
when symlink?
|
1371
1389
|
File.symlink File.readlink(path()), dest
|
1372
|
-
when chardev?
|
1373
|
-
raise "cannot handle device file"
|
1374
|
-
mknod dest, ?c, 0666, lstat().rdev
|
1375
|
-
when blockdev?
|
1376
|
-
raise "cannot handle device file" unless File.respond_to?(:mknod)
|
1377
|
-
mknod dest, ?b, 0666, lstat().rdev
|
1390
|
+
when chardev?, blockdev?
|
1391
|
+
raise "cannot handle device file"
|
1378
1392
|
when socket?
|
1379
|
-
|
1380
|
-
|
1393
|
+
begin
|
1394
|
+
require 'socket'
|
1395
|
+
rescue LoadError
|
1396
|
+
raise "cannot handle socket"
|
1397
|
+
else
|
1398
|
+
raise "cannot handle socket" unless defined?(UNIXServer)
|
1399
|
+
end
|
1400
|
+
UNIXServer.new(dest).close
|
1401
|
+
File.chmod lstat().mode, dest
|
1381
1402
|
when pipe?
|
1382
1403
|
raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
|
1383
|
-
mkfifo dest,
|
1404
|
+
File.mkfifo dest, lstat().mode
|
1384
1405
|
when door?
|
1385
1406
|
raise "cannot handle door: #{path()}"
|
1386
1407
|
else
|
@@ -1499,14 +1520,14 @@ module FileUtils
|
|
1499
1520
|
|
1500
1521
|
private
|
1501
1522
|
|
1502
|
-
|
1523
|
+
@@fileutils_rb_have_lchmod = nil
|
1503
1524
|
|
1504
1525
|
def have_lchmod?
|
1505
1526
|
# This is not MT-safe, but it does not matter.
|
1506
|
-
if
|
1507
|
-
|
1527
|
+
if @@fileutils_rb_have_lchmod == nil
|
1528
|
+
@@fileutils_rb_have_lchmod = check_have_lchmod?
|
1508
1529
|
end
|
1509
|
-
|
1530
|
+
@@fileutils_rb_have_lchmod
|
1510
1531
|
end
|
1511
1532
|
|
1512
1533
|
def check_have_lchmod?
|
@@ -1517,14 +1538,14 @@ module FileUtils
|
|
1517
1538
|
return false
|
1518
1539
|
end
|
1519
1540
|
|
1520
|
-
|
1541
|
+
@@fileutils_rb_have_lchown = nil
|
1521
1542
|
|
1522
1543
|
def have_lchown?
|
1523
1544
|
# This is not MT-safe, but it does not matter.
|
1524
|
-
if
|
1525
|
-
|
1545
|
+
if @@fileutils_rb_have_lchown == nil
|
1546
|
+
@@fileutils_rb_have_lchown = check_have_lchown?
|
1526
1547
|
end
|
1527
|
-
|
1548
|
+
@@fileutils_rb_have_lchown
|
1528
1549
|
end
|
1529
1550
|
|
1530
1551
|
def check_have_lchown?
|
@@ -1546,10 +1567,13 @@ module FileUtils
|
|
1546
1567
|
else
|
1547
1568
|
DIRECTORY_TERM = "(?=/|\\z)"
|
1548
1569
|
end
|
1549
|
-
SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : ""
|
1550
1570
|
|
1551
1571
|
def descendant_directory?(descendant, ascendant)
|
1552
|
-
|
1572
|
+
if File::FNM_SYSCASE.nonzero?
|
1573
|
+
File.expand_path(File.dirname(descendant)).casecmp(File.expand_path(ascendant)) == 0
|
1574
|
+
else
|
1575
|
+
File.expand_path(File.dirname(descendant)) == File.expand_path(ascendant)
|
1576
|
+
end
|
1553
1577
|
end
|
1554
1578
|
end # class Entry_
|
1555
1579
|
|
@@ -1588,13 +1612,13 @@ module FileUtils
|
|
1588
1612
|
end
|
1589
1613
|
private_module_function :fu_same?
|
1590
1614
|
|
1591
|
-
@fileutils_output = $stderr
|
1592
|
-
@fileutils_label = ''
|
1593
|
-
|
1594
1615
|
def fu_output_message(msg) #:nodoc:
|
1595
|
-
@fileutils_output
|
1596
|
-
|
1597
|
-
|
1616
|
+
output = @fileutils_output if defined?(@fileutils_output)
|
1617
|
+
output ||= $stderr
|
1618
|
+
if defined?(@fileutils_label)
|
1619
|
+
msg = @fileutils_label + msg
|
1620
|
+
end
|
1621
|
+
output.puts msg
|
1598
1622
|
end
|
1599
1623
|
private_module_function :fu_output_message
|
1600
1624
|
|
@@ -1605,8 +1629,11 @@ module FileUtils
|
|
1605
1629
|
tbl
|
1606
1630
|
}
|
1607
1631
|
|
1632
|
+
public
|
1633
|
+
|
1608
1634
|
#
|
1609
|
-
# Returns an Array of
|
1635
|
+
# Returns an Array of names of high-level methods that accept any keyword
|
1636
|
+
# arguments.
|
1610
1637
|
#
|
1611
1638
|
# p FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
|
1612
1639
|
#
|
@@ -1645,7 +1672,7 @@ module FileUtils
|
|
1645
1672
|
end
|
1646
1673
|
|
1647
1674
|
#
|
1648
|
-
# Returns an Array of
|
1675
|
+
# Returns an Array of methods names which have the option +opt+.
|
1649
1676
|
#
|
1650
1677
|
# p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
|
1651
1678
|
#
|
@@ -1653,14 +1680,16 @@ module FileUtils
|
|
1653
1680
|
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
|
1654
1681
|
end
|
1655
1682
|
|
1656
|
-
|
1657
|
-
|
1683
|
+
private
|
1684
|
+
|
1685
|
+
LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern) # :nodoc:
|
1686
|
+
module LowMethods # :nodoc: internal use only
|
1658
1687
|
private
|
1659
1688
|
def _do_nothing(*)end
|
1660
1689
|
::FileUtils::LOW_METHODS.map {|name| alias_method name, :_do_nothing}
|
1661
1690
|
end
|
1662
1691
|
|
1663
|
-
METHODS = singleton_methods() - [:private_module_function,
|
1692
|
+
METHODS = singleton_methods() - [:private_module_function, # :nodoc:
|
1664
1693
|
:commands, :options, :have_option?, :options_of, :collect_method]
|
1665
1694
|
|
1666
1695
|
#
|
@@ -1670,8 +1699,6 @@ module FileUtils
|
|
1670
1699
|
#
|
1671
1700
|
module Verbose
|
1672
1701
|
include FileUtils
|
1673
|
-
@fileutils_output = $stderr
|
1674
|
-
@fileutils_label = ''
|
1675
1702
|
names = ::FileUtils.collect_method(:verbose)
|
1676
1703
|
names.each do |name|
|
1677
1704
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
@@ -1695,8 +1722,6 @@ module FileUtils
|
|
1695
1722
|
module NoWrite
|
1696
1723
|
include FileUtils
|
1697
1724
|
include LowMethods
|
1698
|
-
@fileutils_output = $stderr
|
1699
|
-
@fileutils_label = ''
|
1700
1725
|
names = ::FileUtils.collect_method(:noop)
|
1701
1726
|
names.each do |name|
|
1702
1727
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
@@ -1721,8 +1746,6 @@ module FileUtils
|
|
1721
1746
|
module DryRun
|
1722
1747
|
include FileUtils
|
1723
1748
|
include LowMethods
|
1724
|
-
@fileutils_output = $stderr
|
1725
|
-
@fileutils_label = ''
|
1726
1749
|
names = ::FileUtils.collect_method(:noop)
|
1727
1750
|
names.each do |name|
|
1728
1751
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
data/lib/fileutils/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
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: 2019-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Several file utility methods for copying, moving, removing, etc.
|
28
14
|
email:
|
29
15
|
-
|