diff options
Diffstat (limited to 'platform_utils.py')
| -rw-r--r-- | platform_utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/platform_utils.py b/platform_utils.py index 2ad56490..33cb2ec3 100644 --- a/platform_utils.py +++ b/platform_utils.py | |||
| @@ -244,6 +244,23 @@ def rename(src, dst): | |||
| 244 | os.rename(src, dst) | 244 | os.rename(src, dst) |
| 245 | 245 | ||
| 246 | 246 | ||
| 247 | def remove(path): | ||
| 248 | """Remove (delete) the file path. This is a replacement for os.remove, but | ||
| 249 | allows deleting read-only files on Windows. | ||
| 250 | """ | ||
| 251 | if isWindows(): | ||
| 252 | try: | ||
| 253 | os.remove(path) | ||
| 254 | except OSError as e: | ||
| 255 | if e.errno == errno.EACCES: | ||
| 256 | os.chmod(path, stat.S_IWRITE) | ||
| 257 | os.remove(path) | ||
| 258 | else: | ||
| 259 | raise | ||
| 260 | else: | ||
| 261 | os.remove(path) | ||
| 262 | |||
| 263 | |||
| 247 | def islink(path): | 264 | def islink(path): |
| 248 | """Test whether a path is a symbolic link. | 265 | """Test whether a path is a symbolic link. |
| 249 | 266 | ||
