【发布时间】:2015-12-24 18:49:24
【问题描述】:
在我维护的代码中,我遇到了:
from ctypes.wintypes import MAX_PATH
我想把它改成这样的:
try:
from ctypes.wintypes import MAX_PATH
except ValueError: # raises on linux
MAX_PATH = 4096 # see comments
但我找不到任何方法从 python (os, os.path, sys...) 获取最大文件系统路径的值 - 有标准方法还是我需要外部库?
或者说linux中没有类似MAX_PATH的,至少不是发行版中的标准?
try:
MAX_PATH = int(subprocess.check_output(['getconf', 'PATH_MAX', '/']))
except (ValueError, subprocess.CalledProcessError, OSError):
deprint('calling getconf failed - error:', traceback=True)
MAX_PATH = 4096
【问题讨论】:
-
Linux 上是 4096 - unix.stackexchange.com/questions/32795/…
-
@jonrsharpe:没有编程方式来解决它?
标签: linux python-2.7 path filesystems max-path