diff options
Diffstat (limited to 'lib/fileutils.rb')
-rw-r--r-- | lib/fileutils.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index dea39c405b..eaa5434d39 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -170,14 +170,18 @@ module FileUtils return *list if options[:noop] mode = options[:mode] || (0777 & ~File.umask) - list.map {|n| File.expand_path(n) }.each do |dir| + list.map {|n| File.expand_path(n) }.each do |path| stack = [] - until File.directory?(dir) - stack.push dir - dir = File.dirname(dir) + until path == stack.last # dirname("/")=="/", dirname("C:/")=="C:/" + stack.push path + path = File.dirname(path) end - stack.reverse_each do |n| - Dir.mkdir n, mode + stack.reverse_each do |path| + begin + Dir.mkdir path, mode + rescue Errno::EEXIST => err + raise unless File.directory?(path) + end end end |