JuliaLang/julia — pull request #9017 by ninjin (2014-11-15 10:18:03+00:00)
Title: RFC: f(::Function) variants for `mktemp` and `mktempdir`

While making some test code requiring temporary directories I remembered that Python has some awesome temporary file objects that you can combine with `with`-statements to make the clean-up automagical. With this PR, we can be just as awesome with our `do`-blocks:

mktempdir() do d
touch(joinpath(d, "foo.md"))
end

mktemp() do p, io
print(io, "鴨かも？") # Silly Japanese play on words.
end

"Bonus commits":

1. Re-enabling several tests in `test/file.jl`, that were disabled back in 02a6aaba79a379228805c76fb62e3b99496e6b23. For Windows compatibility? Now that Windows support the operations we should be able to re-enable them safely.
2. Moving several Unix-only tmp functions in `file.jl` into a single block protected by a `@unix_only` to follow the same pattern that was used for the corresponding Windows-only code.