Handle that os.pathconf is posix-only

This commit is contained in:
Jakub Roztocil 2016-03-17 16:14:14 +08:00
parent 5300b0b490
commit 557911b606

View File

@ -148,13 +148,17 @@ def trim_filename(filename, max_len):
def get_filename_max_length(directory): def get_filename_max_length(directory):
max_len = 255
try: try:
max_len = os.pathconf(directory, 'PC_NAME_MAX') pathconf = os.pathconf
except OSError as e: except AttributeError:
if e.errno == errno.EINVAL: pass # non-posix
max_len = 255 else:
else: try:
raise max_len = pathconf(directory, 'PC_NAME_MAX')
except OSError as e:
if e.errno != errno.EINVAL:
raise
return max_len return max_len