digitalmars.D.bugs - [Issue 17912] New: Add function to std.file for creating a temporary
- d-bugmail puremagic.com (33/33) Oct 17 2017 https://issues.dlang.org/show_bug.cgi?id=17912
https://issues.dlang.org/show_bug.cgi?id=17912 Issue ID: 17912 Summary: Add function to std.file for creating a temporary file with a name Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: issues.dlang jmdavisProg.com We previously added a function to std.stdio for safely creating a temporary file with a name that could be closed and reopened (unlike std.stdio.File.tmpfile, which has no name and is deleted when it's closed), but it was removed due to the fact that it increased the size of hello world even though it arguably shouldn't have: https://issues.dlang.org/show_bug.cgi?id=14599 I propose that instead of waiting for the compiler to be improved to the point that we can re-add scratchFile to std.stdio without increasing the size of hell world, we add a function to std.file which creates a temporary file and returns its name. It does have the downside that you have to reopen the file if you want to use it with std.stdio.File, but it could optionally accept data like std.file.write does so that it can be created with data rather than having to create it and then reopen it to write to it. And for many (most?) cases where you want a temporary file with a name to be operating on, this arrangement would probably work better than getting a std.stdio.File to write to anyway (e.g. a major use case is creating a temporary file for unit tests where you need a file to read and write to using its name). --
Oct 17 2017