@@ -291,7 +291,7 @@ def remove_trailing_slash(dir) #:nodoc:
291291 #
292292 # Keyword arguments:
293293 #
294- # - <tt>mode: <i>integer </i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
294+ # - <tt>mode: <i>mode </i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
295295 # see {File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
296296 # - <tt>noop: true</tt> - does not create directories.
297297 # - <tt>verbose: true</tt> - prints an equivalent command:
@@ -334,7 +334,7 @@ def mkdir(list, mode: nil, noop: nil, verbose: nil)
334334 #
335335 # Keyword arguments:
336336 #
337- # - <tt>mode: <i>integer </i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
337+ # - <tt>mode: <i>mode </i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
338338 # see {File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
339339 # - <tt>noop: true</tt> - does not create directories.
340340 # - <tt>verbose: true</tt> - prints an equivalent command:
@@ -1177,6 +1177,9 @@ def rm_rf(list, noop: nil, verbose: nil, secure: nil)
11771177 # Avoids a local vulnerability that can exist in certain circumstances;
11781178 # see {Avoiding the TOCTTOU Vulnerability}[rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability].
11791179 #
1180+ # Optional argument +force+ specifies whether to ignore
1181+ # raised exceptions of StandardError and its descendants.
1182+ #
11801183 def remove_entry_secure ( path , force = false )
11811184 unless fu_have_symlink?
11821185 remove_entry path , force
@@ -1263,12 +1266,14 @@ def fu_stat_identical_entry?(a, b) #:nodoc:
12631266 end
12641267 private_module_function :fu_stat_identical_entry?
12651268
1269+ # Removes the entry given by +path+,
1270+ # which should be the entry for a regular file, a symbolic link,
1271+ # or a directory.
12661272 #
1267- # This method removes a file system entry +path+.
1268- # +path+ might be a regular file, a directory, or something.
1269- # If +path+ is a directory, remove it recursively.
1273+ # Optional argument +force+ specifies whether to ignore
1274+ # raised exceptions of StandardError and its descendants.
12701275 #
1271- # See also remove_entry_secure.
1276+ # Related: FileUtils. remove_entry_secure.
12721277 #
12731278 def remove_entry ( path , force = false )
12741279 Entry_ . new ( path ) . postorder_traverse do |ent |
@@ -1283,9 +1288,11 @@ def remove_entry(path, force = false)
12831288 end
12841289 module_function :remove_entry
12851290
1291+ # Removes the file entry given by +path+,
1292+ # which should be the entry for a regular file or a symbolic link.
12861293 #
1287- # Removes a file +path+.
1288- # This method ignores StandardError if +force+ is true .
1294+ # Optional argument +force+ specifies whether to ignore
1295+ # raised exceptions of StandardError and its descendants .
12891296 #
12901297 def remove_file ( path , force = false )
12911298 Entry_ . new ( path ) . remove_file
@@ -1294,20 +1301,20 @@ def remove_file(path, force = false)
12941301 end
12951302 module_function :remove_file
12961303
1304+ # Recursively removes the directory entry given by +path+,
1305+ # which should be the entry for a regular file, a symbolic link,
1306+ # or a directory.
12971307 #
1298- # Removes a directory +dir+ and its contents recursively.
1299- # This method ignores StandardError if +force+ is true .
1308+ # Optional argument +force+ specifies whether to ignore
1309+ # raised exceptions of StandardError and its descendants .
13001310 #
13011311 def remove_dir ( path , force = false )
13021312 remove_entry path , force # FIXME?? check if it is a directory
13031313 end
13041314 module_function :remove_dir
13051315
1306- #
1307- # Returns true if the contents of a file +a+ and a file +b+ are identical.
1308- #
1309- # FileUtils.compare_file('somefile', 'somefile') #=> true
1310- # FileUtils.compare_file('/dev/null', '/dev/urandom') #=> false
1316+ # Returns +true+ if the contents of files +a+ and +b+ are identical,
1317+ # +false+ otherwise.
13111318 #
13121319 def compare_file ( a , b )
13131320 return false unless File . size ( a ) == File . size ( b )
@@ -1324,8 +1331,8 @@ def compare_file(a, b)
13241331 module_function :identical?
13251332 module_function :cmp
13261333
1327- #
1328- # Returns true if the contents of a stream +a+ and +b+ are identical .
1334+ # Returns +true+ if the contents of streams +a+ and +b+ are identical,
1335+ # +false+ otherwise .
13291336 #
13301337 def compare_stream ( a , b )
13311338 bsize = fu_stream_blksize ( a , b )
@@ -1342,13 +1349,60 @@ def compare_stream(a, b)
13421349 end
13431350 module_function :compare_stream
13441351
1352+ # Copies the file entry at path +src+ to the entry at path +dest+;
1353+ # each of +src+ and +dest+ may be a string or a
1354+ # {Pathname}[https://docs.ruby-lang.org/en/master/Pathname.html].
1355+ #
1356+ # See {install(1)}[https://man7.org/linux/man-pages/man1/install.1.html].
1357+ #
1358+ # If the entry at +dest+ does not exist, copies from +src+ to +dest+:
1359+ #
1360+ # File.read('src0.txt') # => "aaa\n"
1361+ # File.exist?('dest0.txt') # => false
1362+ # FileUtils.install('src0.txt', 'dest0.txt')
1363+ # File.read('dest0.txt') # => "aaa\n"
1364+ #
1365+ # If +dest+ is a file entry, copies from +src+ to +dest+, overwriting:
13451366 #
1346- # If +src+ is not same as +dest+, copies it and changes the permission
1347- # mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
1348- # This method removes destination before copy.
1367+ # File.read('src1.txt') # => "aaa\n"
1368+ # File.read('dest1.txt') # => "bbb\n"
1369+ # FileUtils.install('src1.txt', 'dest1.txt')
1370+ # File.read('dest1.txt') # => "aaa\n"
1371+ #
1372+ # If +dest+ is a directory entry, copies from +src+ to <tt>dest/src</tt>,
1373+ # overwriting if necessary:
1374+ #
1375+ # File.read('src2.txt') # => "aaa\n"
1376+ # File.read('dest2/src2.txt') # => "bbb\n"
1377+ # FileUtils.install('src2.txt', 'dest2')
1378+ # File.read('dest2/src2.txt') # => "aaa\n"
1379+ #
1380+ # Keyword arguments:
1381+ #
1382+ # {chown(2)}[https://man7.org/linux/man-pages/man2/chown.2.html]
1383+ # and {chmod(2)}[https://man7.org/linux/man-pages/man2/chmod.2.html]
1384+ #
1385+ #
1386+ # - <tt>group: <i>group</i></tt> - changes the group if not +nil+,
1387+ # using {File.chown}[https://docs.ruby-lang.org/en/master/File.html#method-c-chown].
1388+ # - <tt>mode: <i>permissions</i></tt> - changes the permissions.
1389+ # using {File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
1390+ # - <tt>noop: true</tt> - does not remove entries; returns +nil+.
1391+ # - <tt>owner: <i>owner</i></tt> - changes the owner if not +nil+,
1392+ # using {File.chown}[https://docs.ruby-lang.org/en/master/File.html#method-c-chown].
1393+ # - <tt>preserve: true</tt> - preserve timestamps
1394+ # using {File.utime}[https://docs.ruby-lang.org/en/master/File.html#method-c-utime].
1395+ # - <tt>verbose: true</tt> - prints an equivalent command:
1396+ #
1397+ # FileUtils.install('src0.txt', 'dest0.txt', noop: true, verbose: true)
1398+ # FileUtils.install('src1.txt', 'dest1.txt', noop: true, verbose: true)
1399+ # FileUtils.install('src2.txt', 'dest2', noop: true, verbose: true)
1400+ #
1401+ # Output:
13491402 #
1350- # FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
1351- # FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
1403+ # install -c src0.txt dest0.txt
1404+ # install -c src1.txt dest1.txt
1405+ # install -c src2.txt dest2
13521406 #
13531407 def install ( src , dest , mode : nil , owner : nil , group : nil , preserve : nil ,
13541408 noop : nil , verbose : nil )
0 commit comments