Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-08 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 7 July 2014 at 16:02:33 UTC, Kagamin wrote: On Monday, 7 July 2014 at 14:25:54 UTC, Regan Heath wrote: If I had to guess, I would say it would still be possible to access the file. It's documented so. I guess, linux implements file deletion with delete-on-close feature too, if it

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Kagamin via Digitalmars-d-learn
See if stdio allows you to specify delete sharing when opening the file.

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Kagamin via Digitalmars-d-learn
On windows files are traditionally opened without delete sharing, such files can't be deleted until closed, because all sharing options are always honored.

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Joakim via Digitalmars-d-learn
On Monday, 7 July 2014 at 10:19:01 UTC, Kagamin wrote: See if stdio allows you to specify delete sharing when opening the file. I don't know what delete sharing is exactly, but the File constructor simply calls fopen and I don't see any option for the Windows fopen that seems to do it:

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Regan Heath via Digitalmars-d-learn
On Mon, 07 Jul 2014 12:17:34 +0100, Joakim dl...@joakim.airpost.net wrote: On Monday, 7 July 2014 at 10:19:01 UTC, Kagamin wrote: See if stdio allows you to specify delete sharing when opening the file. I don't know what delete sharing is exactly, but the File constructor simply calls

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread rumbu via Digitalmars-d-learn
On Monday, 7 July 2014 at 11:17:35 UTC, Joakim wrote: On Monday, 7 July 2014 at 10:19:01 UTC, Kagamin wrote: See if stdio allows you to specify delete sharing when opening the file. In std.stdio, File(name, mode) is forwarded to _wfopen on Windows and to fopen on posix. On Windows there

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 7 July 2014 at 12:00:48 UTC, Regan Heath wrote: But! I agree with Adam, leave it as a thin wrapper. Being a windows programmer by trade I would expect the remove to fail, I would not expect all my files to be opened with delete sharing enabled by default. R And I believe

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Kagamin via Digitalmars-d-learn
It can be also a bad user experience, when delete succeeds only pertially and doesn't free the disk space. Delete-on-close flag should be better in this regard.

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Regan Heath via Digitalmars-d-learn
On Mon, 07 Jul 2014 15:18:51 +0100, Jesse Phillips jesse.k.phillip...@gmail.com wrote: On Monday, 7 July 2014 at 12:00:48 UTC, Regan Heath wrote: But! I agree with Adam, leave it as a thin wrapper. Being a windows programmer by trade I would expect the remove to fail, I would not expect

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Kagamin via Digitalmars-d-learn
On Monday, 7 July 2014 at 14:25:54 UTC, Regan Heath wrote: If I had to guess, I would say it would still be possible to access the file. It's documented so. I guess, linux implements file deletion with delete-on-close feature too, if it exists, a separate deletion operation is not needed.

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-07 Thread Joakim via Digitalmars-d-learn
On Monday, 7 July 2014 at 12:00:48 UTC, Regan Heath wrote: On Mon, 07 Jul 2014 12:17:34 +0100, Joakim dl...@joakim.airpost.net wrote: On Monday, 7 July 2014 at 10:19:01 UTC, Kagamin wrote: See if stdio allows you to specify delete sharing when opening the file. I don't know what delete

File needs to be closed on Windows but not on Posix, bug?

2014-07-05 Thread Joakim via Digitalmars-d-learn
I ran into this when trying to fix the Phobos unit tests and have reduced it down to this test file: import std.stdio, std.file; void main() { auto f = File(test.txt, w); //f.close(); std.file.remove(test.txt); } This compiles and runs fine on linux and the autotester shows that

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 July 2014 at 20:23:03 UTC, Joakim wrote: This seems like inconsistent behavior: should I file a bug? This is because the operating systems do it differently; I think D is doing the right thing by being a pretty thin wrapper around that functionality. If anything, I'd just