I'm using mktemp()
to create a file in Julia. Now, from what I understood, by setting the cleanup=true
flag, the file would be deleted once I did close(io)
. In other words:
using Librsvg_jll
(path, io) = mktemp(cleanup=true)
write(io, img)
close(io)
io = open(path, "r")
content = read(io, String)
println(content)
close(io)
This should returns an error saying that the file doesn't exists. But it actually returns the content written in write(io, img)
. I'm using a Jupyter notebook to run this code... What am I missing here?
Double check the mktemp
docstring :-)
mktemp(parent=tempdir(); cleanup=true) -> (path, io)
Return (path, io), where path is the path of a new temporary file in parent and io is an open file object for this path.
The cleanup option controls whether the temporary file is automatically deleted when the process exits.
I thought that close(io)
would mean that the process is exiting. Am I wrong?
No it means the julia process
On this note, is there any "security" issue if I manually do rm(path)
?
I don't think so, but you can use a do block and the file will be removed automatically
mktemp() do path, io
...
end
Davi Sales Barreira has marked this topic as resolved.
Last updated: Nov 06 2024 at 04:40 UTC