forked from extern/httpie-cli
Handle that os.pathconf is posix-only
This commit is contained in:
parent
5300b0b490
commit
557911b606
@ -148,13 +148,17 @@ def trim_filename(filename, max_len):
|
||||
|
||||
|
||||
def get_filename_max_length(directory):
|
||||
max_len = 255
|
||||
try:
|
||||
max_len = os.pathconf(directory, 'PC_NAME_MAX')
|
||||
except OSError as e:
|
||||
if e.errno == errno.EINVAL:
|
||||
max_len = 255
|
||||
else:
|
||||
raise
|
||||
pathconf = os.pathconf
|
||||
except AttributeError:
|
||||
pass # non-posix
|
||||
else:
|
||||
try:
|
||||
max_len = pathconf(directory, 'PC_NAME_MAX')
|
||||
except OSError as e:
|
||||
if e.errno != errno.EINVAL:
|
||||
raise
|
||||
return max_len
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user