[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2017-07-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #15 from github-bugzi...@puremagic.com ---
Commits pushed to dmd-cxx at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/e3e9f2965f438170157338767700bc1d7292dd67
Implement issue# 13996. Add File.scratchFile.

https://github.com/dlang/phobos/commit/8a65ff8db444f35f6322debbb970166b8c587beb
Merge pull request #2956 from jmdavis/tempFile

https://github.com/dlang/phobos/commit/8087f354414ed39f23eec94049a1a154fcbb412c
Revert "Implement issue# 13996. Add File.tempFile."

https://github.com/dlang/phobos/commit/c8c5a3255def4274dcc807e479f5aca1f8177cdf
Merge pull request #3273 from D-Programming-Language/revert-2956-tempFile

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-07-26 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

Timothee Cour timothee.co...@gmail.com changed:

   What|Removed |Added

 CC||timothee.co...@gmail.com

--- Comment #13 from Timothee Cour timothee.co...@gmail.com ---
the pull seems to cause this regression:
https://issues.dlang.org/show_bug.cgi?id=14828

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-07-26 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #14 from Jonathan M Davis issues.dl...@jmdavisprog.com ---
(In reply to Timothee Cour from comment #13)
 the pull seems to cause this regression:
 https://issues.dlang.org/show_bug.cgi?id=14828

I'm not sure how it could be, since it was reverted. Maybe the changes for
scratchFile triggered that bug, were reverted, and now something later is
triggering it. I don't know. But since the changes for this were already
reverted, it's not like we can revert them to fix the regression.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-05-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #12 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/8087f354414ed39f23eec94049a1a154fcbb412c
Revert Implement issue# 13996. Add File.tempFile.

https://github.com/D-Programming-Language/phobos/commit/c8c5a3255def4274dcc807e479f5aca1f8177cdf
Merge pull request #3273 from D-Programming-Language/revert-2956-tempFile

Revert Implement issue# 13996. Add File.tempFile.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-05-10 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #11 from github-bugzi...@puremagic.com ---
Commit pushed to revert-2956-tempFile at
https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/8087f354414ed39f23eec94049a1a154fcbb412c
Revert Implement issue# 13996. Add File.tempFile.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-04-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

Martin Nowak c...@dawg.eu changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-03-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #10 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/e3e9f2965f438170157338767700bc1d7292dd67
Implement issue# 13996. Add File.scratchFile.

This adds a File.scratchFile, which generates a random file name and
returns an open std.stdio.File for it. Unlike with File.tmpfile, it's a
normal file which is _not_ deleted when the file is closed, and you
actually have access to the file's name, which is necessary in many
situations - particularly when writing unit tests that need to write to
a file and then read from it.

https://github.com/D-Programming-Language/phobos/commit/8a65ff8db444f35f6322debbb970166b8c587beb
Merge pull request #2956 from jmdavis/tempFile

Implement issue# 13996. Add File.tempFile.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #9 from github-bugzi...@puremagic.com ---
Commits pushed to 2.067 at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/0f389cb0aa5a8f5fd1a36dbdd338f1560d08ee73
Add declaration for _wsopen. It's needed for issue# 13996.

https://github.com/D-Programming-Language/druntime/commit/af9cabcd48a4fef66213ad84e4eaf8959ce36306
Merge pull request #1154 from jmdavis/_wsopen

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #7 from Jonathan M Davis issues.dl...@jmdavisprog.com ---
Okay. I now have a pull request for this, and I added a suffix parameter to
what I had so that now both a prefix and suffix can be set:

https://github.com/D-Programming-Language/phobos/pull/2956

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #8 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/0f389cb0aa5a8f5fd1a36dbdd338f1560d08ee73
Add declaration for _wsopen. It's needed for issue# 13996.

https://github.com/D-Programming-Language/druntime/commit/af9cabcd48a4fef66213ad84e4eaf8959ce36306
Merge pull request #1154 from jmdavis/_wsopen

Add declaration for _wsopen. It's needed for issue# 13996.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #5 from Martin Nowak c...@dawg.eu ---
 What suffix? As suggested, it takes an optional prefix and randomly generates 
 the rest. You mean that it should take an extension?

Yes, prefix and suffix, random in between.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #6 from Martin Nowak c...@dawg.eu ---
A mkdtemp for directories is missing as well.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #4 from Martin Nowak c...@dawg.eu ---
(In reply to Jonathan M Davis from comment #3)
 auto file = File.tempFile();
 scope(exit) std.file.remove(file.name);

There is a security aspect, because the current tempfile is unlinked at the
moment it's created. So no other process can access it.
But as that's the advanced use-case it deserves the longer name, anonTempFile
or so.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #3 from Jonathan M Davis issues.dl...@jmdavisprog.com ---
Drat. I managed to post by accident. In any case, tmpfile could easily be
replaced such that

auto file = File.tmpfile();

became

auto file = File.tempFile();
scope(exit) std.file.remove(file.name);

so IMHO tmpfile becomes redundant on top of being pretty useless. But it _does_
mean deprecating it if we're getting rid of it, so it might be better to just
keep it around rather than dealing with that.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

Martin Nowak c...@dawg.eu changed:

   What|Removed |Added

 CC||c...@dawg.eu

--- Comment #1 from Martin Nowak c...@dawg.eu ---
You forgot suffix argument :).

It's missing for ages, we just needed it for dub
https://github.com/D-Programming-Language/dub/pull/497#issuecomment-72763326.

The python implementation takes a reasonable approach, generate random names
and try to exclusively open the file.

https://github.com/python/cpython/blob/1196330dedbe741f8a0c418abcd2956fad29837f/Lib/tempfile.py#L191

The new function could be called namedTempFile. It's still useful to have a
tempFile function that directly unlink the file.

--


[Issue 13996] Function for returning a temporary file with a randomly generated name where the name can be accessed

2015-02-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13996

--- Comment #2 from Jonathan M Davis issues.dl...@jmdavisprog.com ---
(In reply to Martin Nowak from comment #1)
 You forgot suffix argument :).

What suffix? As suggested, it takes an optional prefix and randomly generates
the rest. You mean that it should take an extension? Or do you think that it
should take a suffix rather than a prefix? I suppose that if it takes a suffix
rather than a prefix, the extension could just be part of the suffix.

 It's missing for ages, we just needed it for dub
 https://github.com/D-Programming-Language/dub/pull/497#issuecomment-72763326.
 
 The python implementation takes a reasonable approach, generate random names
 and try to exclusively open the file.
 
 https://github.com/python/cpython/blob/
 1196330dedbe741f8a0c418abcd2956fad29837f/Lib/tempfile.py#L191
 
 The new function could be called namedTempFile. It's still useful to have a
 tempFile function that directly unlink the file.

I have a working implementation for Linux. The problem is that I can't figure
out how to get _wsopen or any of its relatives to work on Windows. The linker
fails to find them, even when I verify that they're in snn.lib (or whatever the
name of the library is with the stdio stuff in it that comes with dmc). So, I'm
not quite sure what to do. I could easily create a PR, but it's kind of
pointless if it doesn't work on Windows.

As for keeping tmpfile, I suppose that we could - to avoid forcing anyone to
change their code if nothing else - but in my experience, the function is
utterly useless. And replacing it with tempFile would be trivial. instead of

auto file

--