168
168
# - FileUtils.rm_rf with keyword argument <tt>secure: true</tt>.
169
169
#
170
170
# Finally, this method for moving entries calls \FileUtils.remove_entry_secure
171
- # if the source and destination are on different devices
171
+ # if the source and destination are on different file systems
172
172
# (which means that the "move" is really a copy and remove):
173
173
#
174
174
# - FileUtils.mv with keyword argument <tt>secure: true</tt>.
@@ -555,21 +555,6 @@ def ln(src, dest, force: nil, noop: nil, verbose: nil)
555
555
# "tmp1/tmp3/t2.txt",
556
556
# "tmp1/tmp3/t3.txt"]
557
557
#
558
- # If +src+ is an array of paths to files and +dest+ is the path to a directory,
559
- # for each path +filepath+ in +src+, creates a link at <tt>dest/filepath</tt>
560
- # pointing to that path:
561
- #
562
- # FileUtils.rm_r('tmp1')
563
- # Dir.mkdir('tmp1')
564
- # FileUtils.cp_lr(['tmp0/tmp3/t2.txt', 'tmp0/tmp3/t3.txt'], 'tmp1')
565
- # Dir.glob('**/*.txt')
566
- # # => ["tmp0/tmp2/t0.txt",
567
- # "tmp0/tmp2/t1.txt",
568
- # "tmp0/tmp3/t2.txt",
569
- # "tmp0/tmp3/t3.txt",
570
- # "tmp1/t2.txt",
571
- # "tmp1/t3.txt"]
572
- #
573
558
# If +src+ and +dest+ are both paths to directories,
574
559
# creates links <tt>dest/src</tt> and descendents
575
560
# pointing to +src+ and its descendents:
@@ -586,6 +571,21 @@ def ln(src, dest, force: nil, noop: nil, verbose: nil)
586
571
# "tmp1/tmp0/tmp3/t2.txt",
587
572
# "tmp1/tmp0/tmp3/t3.txt"]
588
573
#
574
+ # If +src+ is an array of paths to files and +dest+ is the path to a directory,
575
+ # for each path +filepath+ in +src+, creates a link at <tt>dest/filepath</tt>
576
+ # pointing to that path:
577
+ #
578
+ # FileUtils.rm_r('tmp1')
579
+ # Dir.mkdir('tmp1')
580
+ # FileUtils.cp_lr(['tmp0/tmp3/t2.txt', 'tmp0/tmp3/t3.txt'], 'tmp1')
581
+ # Dir.glob('**/*.txt')
582
+ # # => ["tmp0/tmp2/t0.txt",
583
+ # "tmp0/tmp2/t1.txt",
584
+ # "tmp0/tmp3/t2.txt",
585
+ # "tmp0/tmp3/t3.txt",
586
+ # "tmp1/t2.txt",
587
+ # "tmp1/t3.txt"]
588
+ #
589
589
# Keyword arguments:
590
590
#
591
591
# - <tt>dereference_root: false</tt> - if +src+ is a symbolic link,
@@ -621,7 +621,7 @@ def cp_lr(src, dest, noop: nil, verbose: nil,
621
621
# and +dest+ (a single path)
622
622
# should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].
623
623
#
624
- # When +src+ is the path to an existing file:
624
+ # If +src+ is the path to an existing file:
625
625
#
626
626
# - When +dest+ is the path to a non-existent file,
627
627
# creates a symbolic link at +dest+ pointing to +src+:
@@ -643,15 +643,15 @@ def cp_lr(src, dest, noop: nil, verbose: nil,
643
643
#
644
644
# FileUtils.ln_s('src1.txt', 'dest1.txt') # Raises Errno::EEXIST.
645
645
#
646
- # When +dest+ is the path to a directory,
646
+ # If +dest+ is the path to a directory,
647
647
# creates a symbolic link at <tt>dest/src</tt> pointing to +src+:
648
648
#
649
649
# FileUtils.touch('src2.txt')
650
650
# FileUtils.mkdir('destdir2')
651
651
# FileUtils.ln_s('src2.txt', 'destdir2')
652
652
# File.symlink?('destdir2/src2.txt') # => true
653
653
#
654
- # When +src+ is an array of paths to existing files and +dest+ is a directory,
654
+ # If +src+ is an array of paths to existing files and +dest+ is a directory,
655
655
# for each child +child+ in +src+ creates a symbolic link <tt>dest/child</tt>
656
656
# pointing to +child+:
657
657
#
@@ -751,7 +751,7 @@ def link_entry(src, dest, dereference_root = false, remove_destination = false)
751
751
end
752
752
module_function :link_entry
753
753
754
- # Copies files from +src+ to +dest+ .
754
+ # Copies files.
755
755
#
756
756
# Arguments +src+ (a single path or an array of paths)
757
757
# and +dest+ (a single path)
@@ -1018,14 +1018,15 @@ def copy_stream(src, dest)
1018
1018
end
1019
1019
module_function :copy_stream
1020
1020
1021
- # Moves files from +src+ (a single path or an array of paths)
1022
- # to +dest+ (a single path).
1023
- # If +src+ and +dest+ are on different devices,
1024
- # first copies, then removes +src+.
1021
+ # Moves entries.
1025
1022
#
1026
- # Arguments +src+ and +dest+
1023
+ # Arguments +src+ (a single path or an array of paths)
1024
+ # and +dest+ (a single path)
1027
1025
# should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].
1028
1026
#
1027
+ # If +src+ and +dest+ are on different file systems,
1028
+ # first copies, then removes +src+.
1029
+ #
1029
1030
# May cause a local vulnerability if not called with keyword argument
1030
1031
# <tt>secure: true</tt>;
1031
1032
# see {Avoiding the TOCTTOU Vulnerability}[rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability].
@@ -1066,7 +1067,7 @@ def copy_stream(src, dest)
1066
1067
# Keyword arguments:
1067
1068
#
1068
1069
# - <tt>force: true</tt> - if the move includes removing +src+
1069
- # (that is, if +src+ and +dest+ are on different devices ),
1070
+ # (that is, if +src+ and +dest+ are on different file systems ),
1070
1071
# ignores raised exceptions of StandardError and its descendants.
1071
1072
# - <tt>noop: true</tt> - does not move files.
1072
1073
# - <tt>secure: true</tt> - removes +src+ securely;
@@ -1457,11 +1458,12 @@ def compare_stream(a, b)
1457
1458
end
1458
1459
module_function :compare_stream
1459
1460
1460
- # Copies the file entry at path +src+ to the entry at path +dest+ ;
1461
+ # Copies a file entry;
1461
1462
# see {install(1)}[https://man7.org/linux/man-pages/man1/install.1.html].
1462
1463
#
1463
- # Arguments +src+ and +dest+
1464
- # should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].
1464
+ # Arguments +src+ (a single path or an array of paths)
1465
+ # and +dest+ (a single path)
1466
+ # should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments];
1465
1467
#
1466
1468
# If the entry at +dest+ does not exist, copies from +src+ to +dest+:
1467
1469
#
@@ -1485,6 +1487,16 @@ def compare_stream(a, b)
1485
1487
# FileUtils.install('src2.txt', 'dest2')
1486
1488
# File.read('dest2/src2.txt') # => "aaa\n"
1487
1489
#
1490
+ # If +src+ is an array of paths and +dest+ points to a directory,
1491
+ # copies each path +path+ in +src+ to <tt>dest/path</tt>:
1492
+ #
1493
+ # File.file?('src3.txt') # => true
1494
+ # File.file?('src3.dat') # => true
1495
+ # FileUtils.mkdir('dest3')
1496
+ # FileUtils.install(['src3.txt', 'src3.dat'], 'dest3')
1497
+ # File.file?('dest3/src3.txt') # => true
1498
+ # File.file?('dest3/src3.dat') # => true
1499
+ #
1488
1500
# Keyword arguments:
1489
1501
#
1490
1502
# - <tt>group: <i>group</i></tt> - changes the group if not +nil+,
0 commit comments