lib/fileutils.rb in fileutils-1.7.0 vs lib/fileutils.rb in fileutils-1.7.1

- old
+ new

@@ -178,11 +178,11 @@ # # - {CVE-2005-0448}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448]. # - {CVE-2004-0452}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452]. # module FileUtils - VERSION = "1.7.0" + VERSION = "1.7.1" def self.private_module_function(name) #:nodoc: module_function name private_class_method name end @@ -190,12 +190,10 @@ # # Returns a string containing the path to the current directory: # # FileUtils.pwd # => "/rdoc/fileutils" # - # FileUtils.getwd is an alias for FileUtils.pwd. - # # Related: FileUtils.cd. # def pwd Dir.pwd end @@ -233,12 +231,10 @@ # Output: # # cd .. # cd fileutils # - # FileUtils.chdir is an alias for FileUtils.cd. - # # Related: FileUtils.pwd. # def cd(dir, verbose: nil, &block) # :yield: dir fu_output_message "cd #{dir}" if verbose result = Dir.chdir(dir, &block) @@ -513,12 +509,10 @@ # ln tmp0/t.txt tmp2/t.dat tmp4/ # # Raises an exception if +dest+ is the path to an existing file # and keyword argument +force+ is not +true+. # - # FileUtils#link is an alias for FileUtils#ln. - # # Related: FileUtils.link_entry (has different options). # def ln(src, dest, force: nil, noop: nil, verbose: nil) fu_output_message "ln#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose return if noop @@ -705,12 +699,10 @@ # ln -s src0.txt dest0.txt # ln -s src1.txt destdir1 # ln -sf src2.txt dest2.txt # ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3 # - # FileUtils.symlink is an alias for FileUtils.ln_s. - # # Related: FileUtils.ln_sf. # def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil) if relative return ln_sr(src, dest, force: force, noop: noop, verbose: verbose) @@ -874,12 +866,10 @@ # cp src1.txt dest1 # cp src2.txt src2.dat dest2 # # Raises an exception if +src+ is a directory. # - # FileUtils.copy is an alias for FileUtils.cp. - # # Related: {methods for copying}[rdoc-ref:FileUtils@Copying]. # def cp(src, dest, preserve: nil, noop: nil, verbose: nil) fu_output_message "cp#{preserve ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if verbose return if noop @@ -1162,12 +1152,10 @@ # Output: # # mv src0 dest0 # mv src1.txt src1 dest1 # - # FileUtils.move is an alias for FileUtils.mv. - # def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil) fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose return if noop fu_each_src_dest(src, dest) do |s, d| destent = Entry_.new(d, nil, true) @@ -1221,12 +1209,10 @@ # # Output: # # rm src0.dat src0.txt # - # FileUtils.remove is an alias for FileUtils.rm. - # # Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting]. # def rm(list, force: nil, noop: nil, verbose: nil) list = fu_list(list) fu_output_message "rm#{force ? ' -f' : ''} #{list.join ' '}" if verbose @@ -1248,12 +1234,10 @@ # Argument +list+ (a single path or an array of paths) # should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments]. # # See FileUtils.rm for keyword arguments. # - # FileUtils.safe_unlink is an alias for FileUtils.rm_f. - # # Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting]. # def rm_f(list, noop: nil, verbose: nil) rm list, force: true, noop: noop, verbose: verbose end @@ -1337,12 +1321,10 @@ # <tt>secure: true</tt>; # see {Avoiding the TOCTTOU Vulnerability}[rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability]. # # See FileUtils.rm_r for keyword arguments. # - # FileUtils.rmtree is an alias for FileUtils.rm_rf. - # # Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting]. # def rm_rf(list, noop: nil, verbose: nil, secure: nil) rm_r list, force: true, noop: noop, verbose: verbose, secure: secure end @@ -1640,10 +1622,16 @@ gid = fu_get_gid(group) fu_each_src_dest(src, dest) do |s, d| st = File.stat(s) unless File.exist?(d) and compare_file(s, d) remove_file d, true - copy_file s, d + if d.end_with?('/') + mkdir_p d + copy_file s, d + File.basename(s) + else + mkdir_p File.expand_path('..', d) + copy_file s, d + end File.utime st.atime, st.mtime, d if preserve File.chmod fu_mode(mode, st), d if mode File.chown uid, gid, d if uid or gid end end