diff --git a/lib/rscons/cache.rb b/lib/rscons/cache.rb index a9e240e..28dcfa8 100644 --- a/lib/rscons/cache.rb +++ b/lib/rscons/cache.rb @@ -181,6 +181,7 @@ module Rscons def mkdir_p(path) parts = path.split(/[\\\/]/) parts.each_index do |i| + next if parts[i] == "" subpath = File.join(*parts[0, i + 1]) unless File.exists?(subpath) FileUtils.mkdir(subpath) diff --git a/spec/rscons/cache_spec.rb b/spec/rscons/cache_spec.rb index 5b30a8c..1f72003 100644 --- a/spec/rscons/cache_spec.rb +++ b/spec/rscons/cache_spec.rb @@ -225,6 +225,16 @@ module Rscons cache.mkdir_p("one\\two\\four") cache.directories.should == ["one/two", "one/two/three", "one/two/four"] end + + it "handles absolute paths" do + _cache = {} + cache = build_from(_cache) + File.should_receive(:exists?).with("/one").and_return(true) + File.should_receive(:exists?).with("/one/two").and_return(false) + FileUtils.should_receive(:mkdir).with("/one/two") + cache.mkdir_p("/one/two") + cache.directories.should == ["/one/two"] + end end describe "#directories" do