Getting a safe path for a temporary file

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 17 06:36:59 PST 2015


On Saturday, 17 January 2015 at 13:47:39 UTC, Marc Schütz wrote:
> Is it currently possible to get the path to a safe temporary 
> file, i.e. one that is guaranteed to be freshly created and 
> will not override another existing file?
>
> There's `std.file.tempDir`, which doesn't create a unique file. 
> Then there's `std.stdio.tmpfile()`, which does, but it returns 
> a `File` object, and its `name` property is `null`.
>
> Did I miss something? IMO this is very import functionality. 
> One use case is passing these names as command line arguments 
> to an external program that doesn't support stdin/stdout.

I agree that it would be useful.

This is what I used, although there may be a better option:

http://dlang.org/phobos/std_uuid.html


More information about the Digitalmars-d-learn mailing list