You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1015 B

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