Skip to content

Commit

Permalink
tempdir: error on non-directory result
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Nov 7, 2019
1 parent 3b11bf3 commit 5f0d075
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,18 @@ function tempdir()
rc = ccall(:uv_os_tmpdir, Cint, (Ptr{UInt8}, Ptr{Csize_t}), buf, sz)
if rc == 0
resize!(buf, sz[])
return String(buf)
break
elseif rc == Base.UV_ENOBUFS
resize!(buf, sz[] - 1) # space for null-terminator implied by StringVector
else
uv_error(:tmpdir, rc)
end
end
p = String(buf)
s = stat(p)
ispath(s) || error("tempdir path does not exist: $p")
isdir(s) || error("tempdir path is not a directory: $p")
return p
end

const TEMP_CLEANUP_MIN = Ref(1024)
Expand Down

0 comments on commit 5f0d075

Please sign in to comment.