Validating destination file paths
ERROR_INVALID_NAME = 123 ''' Windows-specific error code indicating an invalid pathname.
See Also ---------- https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85)Official listing of all such codes.
''' # If this pathname is either not a string or is but is empty, this pathname # is invalid.Unless this # is the case, this exception implies an ignorable kernel or # filesystem complaint (e.g., path not found or inaccessible).# # Only the following exceptions indicate invalid pathnames: # # * Instances of the Windows-specific "Windows Error" class # defining the "winerror" attribute whose value is # "ERROR_INVALID_NAME".Malicious users may attempt to repeatedly validate pathnames residing on filesystems known to be stale or otherwise slow (e.g., NFS Samba shares); in that case, blindly statting incoming pathnames is liable to either eventually fail with connection timeouts or consume more time and resources than your feeble capacity to withstand unemployment.
import errno, os # Sadly, Python fails to provide the following magic number for us.
This function is guaranteed to _never_ raise exceptions.