|
1 from __future__ import unicode_literals |
|
2 |
|
3 import errno |
|
4 from .compat import PY3 |
|
5 |
|
6 if PY3: |
|
7 _permission_error = PermissionError |
|
8 else: |
|
9 _permission_error = OSError |
|
10 |
|
11 class TrashPermissionError(_permission_error): |
|
12 """A permission error specific to a trash directory. |
|
13 |
|
14 Raising this error indicates that permissions prevent us efficiently |
|
15 trashing a file, although we might still have permission to delete it. |
|
16 This is *not* used when permissions prevent removing the file itself: |
|
17 that will be raised as a regular PermissionError (OSError on Python 2). |
|
18 |
|
19 Application code that catches this may try to simply delete the file, |
|
20 or prompt the user to decide, or (on Freedesktop platforms), move it to |
|
21 'home trash' as a fallback. This last option probably involves copying the |
|
22 data between partitions, devices, or network drives, so we don't do it as |
|
23 a fallback. |
|
24 """ |
|
25 def __init__(self, filename): |
|
26 _permission_error.__init__(self, errno.EACCES, "Permission denied", |
|
27 filename) |