I'd like to create a file with exclusive flag.
If file exist I try to use it, if not I'd like to create it.
Python (and underlying library) works differently with/without O_EXCL
flag. Is this okay. How I should use this.
Has somebody manual :-) ?
Eino Mäkitalo
see scenarios (1 without flag ) (2 with flag)
Scenario 1:
To create file if it's not available this works ok
aa=os.open("c:\\temp\\a.txt",os.O_RDWR|os.O_CREAT)
os.close(aa)
aa=os.open("c:\\temp\\a.txt",os.O_RDWR|os.O_CREAT)
os.close(aa)
Scenario 2:
But if you try to do same with O_EXCL then it does not use same logic???
aa=os.open("c:\\temp\\a.txt",os.O_RDWR|os.O_EXCL|o s.O_CREAT)
os.close(aa)
aa=os.open("c:\\temp\\a.txt",os.O_RDWR|os.O_CREAT)
Traceback (most recent call last):
File "<string>", line 1, in <string>
OSError: [Errno 17] File exists: 'c:\\temp\\a.txt'