def max_filename_length(path, limit=MAX_FILENAME_LENGTH):
 if hasattr(os, 'statvfs'):
  try:
   res = os.statvfs(path)
  except OSError:
   return limit
  return min(res[9], limit)
 else:
  return limit

def max_filename_length ( path , limit = MAX_FILENAME_LENGTH ) : if hasattr ( os , 'statvfs' ) : try : res = os . statvfs ( path ) except OSError : return limit return min ( res [ 9 ] , limit ) else : return limit
attempt to determine the maximum filename length for the filesystem containing path .