diff --git a/base/file.jl b/base/file.jl index 64135e559e17b..7ebf4535ef00a 100644 --- a/base/file.jl +++ b/base/file.jl @@ -206,13 +206,13 @@ julia> readdir("test") function mkpath(path::AbstractString; mode::Integer = 0o777) isdirpath(path) && (path = dirname(path)) dir = dirname(path) - (path == dir || isdir(path)) && return + (path == dir || isdir(path)) && return path mkpath(dir, mode = checkmode(mode)) try mkdir(path, mode = mode) - # If there is a problem with making the directory, but the directory - # does in fact exist, then ignore the error. Else re-throw it. catch err + # If there is a problem with making the directory, but the directory + # does in fact exist, then ignore the error. Else re-throw it. if !isa(err, SystemError) || !isdir(path) rethrow() end diff --git a/test/file.jl b/test/file.jl index ce08496cdb95b..2164844ca5031 100644 --- a/test/file.jl +++ b/test/file.jl @@ -1015,13 +1015,15 @@ rm(dir) mktempdir() do dir name1 = joinpath(dir, "apples") name2 = joinpath(dir, "bannanas") - @test touch(name1)==name1 + @test touch(name1) == name1 # when it doesn't exist + @test touch(name1) == name1 # when it does exist @test mv(name1, name2) == name2 @test cp(name2, name1) == name1 namedir = joinpath(dir, "chalk") namepath = joinpath(dir, "chalk","cheese","fresh") - @test mkdir(namedir) == namedir - @test mkpath(namepath) == namepath + @test mkdir(namedir) == namedir # when it doesn't exist + @test mkpath(namepath) == namepath # when it doesn't exist + @test mkpath(namepath) == namepath # when it does exist end