def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a # 250 character directory in the cwd (except - cwd may be on a drive # not supporting \\\\?\\ (eg, network share) - so use temp. import win32file basename = "a" * 250 # but we need to ensure we use the 'long' version of the # temp dir for later comparison. long_temp_dir = win32api.GetLongPathNameW(tempfile.gettempdir()) fname = "\\\\?\\" + os.path.join(long_temp_dir, basename) try: win32file.CreateDirectoryW(fname, None) except win32api.error as details: if details.winerror != winerror.ERROR_ALREADY_EXISTS: raise try: # GetFileAttributes automatically calls GetFileAttributesW when # passed unicode try: attr = win32api.GetFileAttributes(fname) except win32api.error as details: if details.winerror != winerror.ERROR_FILENAME_EXCED_RANGE: raise attr = win32api.GetFileAttributes(str(fname)) assert attr & win32con.FILE_ATTRIBUTE_DIRECTORY, attr long_name = win32api.GetLongPathNameW(fname) assert long_name.lower() == fname.lower() finally: win32file.RemoveDirectory(fname)
def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a # 250 character directory in the cwd. import win32file basename = "a" * 250 fname = "\\\\?\\" + os.path.join(os.getcwd(), basename) try: win32file.CreateDirectoryW(fname, None) except win32api.error, details: if details[0] != winerror.ERROR_ALREADY_EXISTS: raise
def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a # 250 character directory in the cwd (except - cwd may be on a drive # not supporting \\\\?\\ (eg, network share) - so use temp. import win32file basename = "a" * 250 # but we need to ensure we use the 'long' version of the # temp dir for later comparison. long_temp_dir = win32api.GetLongPathNameW(tempfile.gettempdir()) fname = "\\\\?\\" + os.path.join(long_temp_dir, basename) try: win32file.CreateDirectoryW(fname, None) except win32api.error, details: if details.winerror!=winerror.ERROR_ALREADY_EXISTS: raise