lib/fileutils.rb in fileutils-1.4.0 vs lib/fileutils.rb in fileutils-1.4.1

- old
+ new

@@ -100,11 +100,11 @@ # This module has all methods of FileUtils module, but never changes # files/directories. This equates to passing the <tt>:noop</tt> and # <tt>:verbose</tt> flags to methods in FileUtils. # module FileUtils - VERSION = "1.4.0" + VERSION = "1.4.1" def self.private_module_function(name) #:nodoc: module_function name private_class_method name end @@ -915,12 +915,15 @@ end end private_module_function :apply_mask def symbolic_modes_to_i(mode_sym, path) #:nodoc: - path = File.stat(path) unless File::Stat === path - mode = path.mode + mode = if File::Stat === path + path.mode + else + File.stat(path).mode + end mode_sym.split(/,/).inject(mode & 07777) do |current_mode, clause| target, *actions = clause.split(/([=+-])/) raise ArgumentError, "invalid file mode: #{mode_sym}" if actions.empty? target = 'a' if target.empty? user_mask = user_mask(target) @@ -933,10 +936,10 @@ when "w" mask | 0222 when "x" mask | 0111 when "X" - if path.directory? + if FileTest.directory? path mask | 0111 else mask end when "s"