Skip to content

Commit

Permalink
Simplify loop to find out segments to be created
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deivid-rodriguez committed Oct 7, 2021
1 parent 3223c40 commit df08e12
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,10 @@ def mkdir_p(list, mode: nil, noop: nil, verbose: nil)
end

stack = []
until path == stack.last # dirname("/")=="/", dirname("C:/")=="C:/"
until File.directory?(path)
stack.push path
path = File.dirname(path)
break if File.directory?(path)
end
stack.pop if path == stack.last # root directory should exist
stack.reverse_each do |dir|
begin
fu_mkdir dir, mode
Expand Down

0 comments on commit df08e12

Please sign in to comment.