mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
[ruby/fileutils] Simplify loop to find out segments to be created
Doing it this way is simpler and it doesn't end up adding "/" to the
list of folders, so it doesn't need to be removed later.
df08e124ce
This commit is contained in:
parent
a4f2aafd3a
commit
d8d97872a1
1 changed files with 1 additions and 3 deletions
|
@ -220,12 +220,10 @@ module FileUtils
|
||||||
end
|
end
|
||||||
|
|
||||||
stack = []
|
stack = []
|
||||||
until path == stack.last # dirname("/")=="/", dirname("C:/")=="C:/"
|
until File.directory?(path)
|
||||||
stack.push path
|
stack.push path
|
||||||
path = File.dirname(path)
|
path = File.dirname(path)
|
||||||
break if File.directory?(path)
|
|
||||||
end
|
end
|
||||||
stack.pop if path == stack.last # root directory should exist
|
|
||||||
stack.reverse_each do |dir|
|
stack.reverse_each do |dir|
|
||||||
begin
|
begin
|
||||||
fu_mkdir dir, mode
|
fu_mkdir dir, mode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue