Skip to content

Commit 775c75a

Browse files
authored
Merge pull request #100 from deivid-rodriguez/fix-mkdir-p-regression
Fix mkdir_p regression
2 parents 332025b + 9cc6a08 commit 775c75a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/fileutils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def mkdir_p(list, mode: nil, noop: nil, verbose: nil)
374374
path = remove_trailing_slash(item)
375375

376376
stack = []
377-
until File.directory?(path)
377+
until File.directory?(path) || File.dirname(path) == path
378378
stack.push path
379379
path = File.dirname(path)
380380
end

test/fileutils/test_fileutils.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,14 @@ def test_mkdir_p_root
10981098
ensure
10991099
Dir.rmdir(drive) if drive and File.directory?(drive)
11001100
end
1101+
1102+
def test_mkdir_p_offline_drive
1103+
offline_drive = ("A".."Z").to_a.reverse.find {|d| !File.exist?("#{d}:/") }
1104+
1105+
assert_raise(Errno::ENOENT) {
1106+
mkdir_p "#{offline_drive}:/new_dir"
1107+
}
1108+
end
11011109
end
11021110

11031111
def test_mkdir_p_file_perm

0 commit comments

Comments
 (0)