Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def mkdir_p(list, mode: nil, noop: nil, verbose: nil)
path = remove_trailing_slash(item)

stack = []
until File.directory?(path)
until File.directory?(path) || File.dirname(path) == path
stack.push path
path = File.dirname(path)
end
Expand Down
8 changes: 8 additions & 0 deletions test/fileutils/test_fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,14 @@ def test_mkdir_p_root
ensure
Dir.rmdir(drive) if drive and File.directory?(drive)
end

def test_mkdir_p_offline_drive
offline_drive = ("A".."Z").to_a.reverse.find {|d| !File.exist?("#{d}:/") }

assert_raise(Errno::ENOENT) {
mkdir_p "#{offline_drive}:/new_dir"
}
end
end

def test_mkdir_p_file_perm
Expand Down