My goal is to know if a file is locked by another process or not, even if I don't have access to that file!
So to be more clear, let's say I'm opening the file using python's builtin open() with 'wb' switch (for writing). open() will throw IOError with errno 13 (EACCES) if
- the user does not have permission to the file or
- the file is locked by another process
How can I detect case (2) here ?
my target platform is Windows!
According to the docs:
So just do this:
Figure out the errno code from there, and you're set.
You can use
os.access
for checking your access permission. If access permissions are good, then it has to be the second case.