Cleanly removing files and directories, handling WindowsErrors.
The problem of MS Windows not releasing the file handle on a close()
call is handled. This method should be resilient to the strange MS
Windows behaviour of not releasing the relax state files. It should
complete even when this WindowsError occurs. A delay of 3 seconds has
been added when the WindowsError occurs to give the OS some time before
attempting to delete the directory or file again. If this fails the
deletion operation is skipped.
- Parameters:
obj (Python object) - The base object containing the file or directory name variable.
name (str) - The name of the file or directory name variable.
dir - A flag which if True indicates that a directory should be
removed. Otherwise a file should be deleted.
|