Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
musm committed Nov 22, 2019
1 parent 6d47522 commit a0fec89
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ function mktemp(parent::AbstractString=tempdir(); cleanup::Bool=true)
return (filename, Base.open(filename, "r+"))
end

# GUID win32 api
# TODO: refactor
# GUID win32 api (consider # TODO: refactor)
struct GUID
l1::Culong
w1::Cushort
Expand All @@ -537,18 +536,14 @@ function tempname(parent::AbstractString=tempdir(); cleanup::Bool=true)
r = ccall((:UuidToStringW, :Rpcrt4), stdcall, Cint, (Ref{GUID}, Ref{Ptr{Cwchar_t}}), id, nameptr)
r == 0 || (r == RPC_S_OUT_OF_MEMORY && error("Out of memory")) || error("cannot convert UIUD to string")

namebuf = unsafe_wrap(Vector{Cwchar_t}, stdcall, nameptr[], ccall(:wcslen, UInt, (Ptr{Cwchar_t},), nameptr[]))
namebuf = unsafe_wrap(Vector{Cwchar_t}, nameptr[], ccall(:wcslen, UInt, (Ptr{Cwchar_t},), nameptr[]))
name = transcode(String, namebuf)

ccall((:RpcStringFreeW, :Rpcrt4), stdcall, Cint, (Ref{Ptr{Cwchar_t}},), nameptr) == 0

filename = joinpath(parent, temp_prefix * name)
if !cleanup
return filename
else
# in the unlikley scenario filename is a path, call this function again regenerate a unique filename
return !ispath(filename) ? (temp_cleanup_later(filename); filename) : tempname(parent; cleanup=cleanup)
end
cleanup && temp_cleanup_later(filename)
return filename
end

else # !windows
Expand Down

0 comments on commit a0fec89

Please sign in to comment.