lib/fileutils.rb in fileutils-1.3.0 vs lib/fileutils.rb in fileutils-1.4.0
- old
+ new
@@ -4,12 +4,10 @@
require 'rbconfig'
rescue LoadError
# for make mjit-headers
end
-require_relative "fileutils/version"
-
#
# = fileutils.rb
#
# Copyright (c) 2000-2007 Minero Aoki
#
@@ -102,10 +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"
def self.private_module_function(name) #:nodoc:
module_function name
private_class_method name
end
@@ -916,15 +915,12 @@
end
end
private_module_function :apply_mask
def symbolic_modes_to_i(mode_sym, path) #:nodoc:
- mode = if File::Stat === path
- path.mode
- else
- File.stat(path).mode
- end
+ path = File.stat(path) unless File::Stat === path
+ mode = path.mode
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)
@@ -937,11 +933,11 @@
when "w"
mask | 0222
when "x"
mask | 0111
when "X"
- if FileTest.directory? path
+ if path.directory?
mask | 0111
else
mask
end
when "s"
@@ -1298,10 +1294,11 @@
else
Dir.entries(path(), **opts)
.reject {|n| n == '.' or n == '..' }
end
- files.map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
+ untaint = RUBY_VERSION < '2.7'
+ files.map {|n| Entry_.new(prefix(), join(rel(), untaint ? n.untaint : n)) }
end
def stat
return @stat if @stat
if lstat() and lstat().symlink?