Validating destination file paths Shat xxx

Posted by / 13-Jan-2021 06:27

# * Instances of the cross-platform "OSError" class defining the # generic "errno" attribute whose value is either: # * Under most POSIX-compatible OSes, "ENAMETOOLONG".

# * Under some edge-case OSes (e.g., Sun OS, *BSD), "ERANGE".

ERROR_INVALID_NAME = 123 ''' Windows-specific error code indicating an invalid pathname.

See Also ---------- listing of all such codes.

''' # If this pathname is either not a string or is but is empty, this pathname # is invalid.return is_pathname_valid(pathname) and ( exists(pathname) or is_path_creatable(pathname)) # Report failure on non-fatal filesystem complaints (e.g., connection # timeouts, permissions issues) implying this path to be inaccessible.All # other exceptions are unrelated fatal issues and should not be caught here.root_dirname = os.environ.get('HOMEDRIVE', 'C:') \ if sys.platform == 'win32' else sep assert isdir(root_dirname) # ...Murphy and her ironclad Law # Append a path separator to this directory if needed.

validating destination file paths-32validating destination file paths-16validating destination file paths-35

Under Windows, "winerror" is more # fine-grained and hence useful than the generic "errno" # attribute.