Message164514
I wrote in an earlier message that a file opened with O_TEMPORARY must be reopened with O_TEMPORARY. This is not quite accurate.
Using O_TEMPORARY causes the FILE_SHARE_DELETE sharing mode to be used, and a file currently opened with FILE_SHARE_DELETE can only be reopened with FILE_SHARE_DELETE.
Unfortunately using O_TEMPORARY is the only way allowed by msvcrt to get FILE_SHARE_DELETE, even though it also has the orthogonal effect of unlinking the file when all handles are closed.
The nice thing about FILE_SHARE_DELETE is that it gives Unix-like behaviour: the file can be renamed or deleted while you have an open handle, and you can still continue to use the handle.
Attached is a mostly untested attempt at writing replacements for open() and os.open() which use the FILE_SHARE_DELETE sharing mode. Among other things, these can be used for reopening temporary files.
Even if tempfile does not use make use of this, I think something similar would be useful in the stdlib. |
|
Date |
User |
Action |
Args |
2012-07-02 13:34:37 | sbt | set | recipients:
+ sbt, jaraco, ncoghlan, pitrou, eric.smith, tim.golden, eric.araujo, r.david.murray, brian.curtin, dabrahams, davide.rizzo, dlenski |
2012-07-02 13:34:37 | sbt | set | messageid: <1341236077.02.0.845745751602.issue14243@psf.upfronthosting.co.za> |
2012-07-02 13:34:36 | sbt | link | issue14243 messages |
2012-07-02 13:34:35 | sbt | create | |
|