mirror of
https://github.com/httpie/cli.git
synced 2025-06-20 17:47:48 +02:00
Handle that os.pathconf is posix-only
This commit is contained in:
parent
5300b0b490
commit
557911b606
@ -148,12 +148,16 @@ def trim_filename(filename, max_len):
|
|||||||
|
|
||||||
|
|
||||||
def get_filename_max_length(directory):
|
def get_filename_max_length(directory):
|
||||||
try:
|
|
||||||
max_len = os.pathconf(directory, 'PC_NAME_MAX')
|
|
||||||
except OSError as e:
|
|
||||||
if e.errno == errno.EINVAL:
|
|
||||||
max_len = 255
|
max_len = 255
|
||||||
|
try:
|
||||||
|
pathconf = os.pathconf
|
||||||
|
except AttributeError:
|
||||||
|
pass # non-posix
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
|
max_len = pathconf(directory, 'PC_NAME_MAX')
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno != errno.EINVAL:
|
||||||
raise
|
raise
|
||||||
return max_len
|
return max_len
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user