Skip to content

Commit

Permalink
windows errors
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Dec 6, 2016
1 parent 29ca339 commit eca7c4a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fs/error_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import errno
from contextlib import contextmanager
import sys
import platform

from . import errors

from six import reraise


_WINDOWS_PLATFORM = platform.system() == 'Windows'


class _ConvertOSErrors(object):
"""Context manager to convert OSErrors in to FS Errors."""

Expand All @@ -31,14 +35,18 @@ class _ConvertOSErrors(object):
errno.ECONNRESET: errors.RemoteConnectionError,
errno.ENAMETOOLONG: errors.PathError,
errno.EOPNOTSUPP: errors.Unsupported,
errno.ENOSYS: errors.Unsupported
errno.ENOSYS: errors.Unsupported,
}

DIR_ERRORS = FILE_ERRORS.copy()
DIR_ERRORS[errno.ENOTDIR] = errors.DirectoryExpected
DIR_ERRORS[errno.EEXIST] = errors.DirectoryExists
DIR_ERRORS[errno.EINVAL] = errors.DirectoryExpected
DIR_ERRORS[267] = errors.DirectoryExpected

if _WINDOWS_PLATFORM:
DIR_ERRORS[13] = errors.DirectoryExpected
DIR_ERRORS[267] = errors.DirectoryExpected
FILE_ERRORS[13] = errors.FileExpected

def __init__(self, opname, path, directory=False):
self._opname = opname
Expand Down

0 comments on commit eca7c4a

Please sign in to comment.