>
> As before, this is *completely untested*. Please read the code
> carefully and see if it makes sense. I'll go give it a shot on Linux
> now; Graham, can you please give it a try on Windows? Also, can someone
> test to see if O_EXCL actually works on Windows?
I'll try to test it tonight.
In the meantime, running this on Windows:
import os
f = open('1.txt', 'w')
f.write('hello')
f.close()
f2 = os.fdopen(os.open('1.txt', os.O_WRONLY | os.O_EXCL | os.O_CREAT))
returns:
Traceback (most recent call last):
File "C:\temp\1.py", line 7, in ?
f2 = os.fdopen(os.open('1.txt', os.O_WRONLY | os.O_EXCL |
os.O_CREAT))
OSError: [Errno 17] File exists: '1.txt'
That's great! I thought I had to use the nasty win32file API to do that.
Thanks!
-- Graham