Hi Martin, On 4/29/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > The error Windows reports is ERROR_SHARING_VIOLATION. I never > understood sharing fully, but it may be that if the file is opened > in "exclusive sharing", stat'ing it may fail.
Sharing is actually very easy. If you didn't specify SHARE_READ/SHARE_WRITE/SHARE_DELETE when opening the file and you succeeded, then any process can't read/write/delete the file until you close the handle. > I personally consider it a bug in Windows that you cannot get file > attributes if some other process has opened it. Exclusive access > should only restrict access to file contents, but not file attributes. After doing some research I found that it seems to be impossible to use CreateFile for a file that doesn't have SHARE_READ. I played with different combinations and with FLAG_BACKUP_SEMANTICS and nothing helped. However on Windows there's still a possibility to read attributes: use FindFirstFile. _WIN32_FIND_DATA structure seems to have all the necessary fields (attributes, file times, size and full/short filename), and FindFirstFile doesn't care about sharing at all... _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com