-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend mktemp to support file suffixes. #13969
Conversation
needs tests, docs, and if possible a windows implementation (if not, an error) edit: and the do-block form below with |
Updated. I force-pushed, because I reverted the change from |
Can you explain the purpose of this PR? The Win32 API doesn't support suffixes (https://msdn.microsoft.com/en-us/library/windows/desktop/aa364991%28v=vs.85%29.aspx) so that would need to be reimplemented from scratch, and suffixes are not used much on unix systems so they should not have much value there. |
I was using Julia to interface with an application whose behaviour depends on the file extension, hence I needed to create temporary files with a specific suffix. Didn't seem unreasonable to me, and I had used Python's I botched the Windows version though, not understanding Or I just close this PR and don't add support for suffixes... |
ref #9053, still need to fix that |
close(f) | ||
@test isfile(p) == true | ||
@test endswith(p, ".foo") == true | ||
rm(p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use do block in mktemp to avoid both close and rm.
This PR extends
mktemp
to support file suffixes using themkstemps
function:Additionally, I've also changed the ccall signature from
Ptr{UInt8}
toCstring
. My understanding is thatCstring
is meant to be used when a string is NULL-terminated, and according to this document the template parameter tomkstemp
and others is supposed to be terminated as such.Am I reading this correctly? If so, I think other functions (
tempnam
,mktempdir
) might need adjusting too.