Skip to content

Commit

Permalink
Handle that os.pathconf is posix-only
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbrzt committed Mar 17, 2016
1 parent 5300b0b commit 557911b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions httpie/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 557911b

Please sign in to comment.