documentation for os.pathconf()
(或Python 2相同)只是模糊地暗示了一组键,其含义在其他各个地方指定;
返回与指定文件相关的系统配置信息。
name
指定要检索的配置值;它可以是一个字符串,它是已定义系统值的名称;这些名称在许多标准(POSIX.1,Unix 95,Unix 98和其他标准)中指定。一些平台也定义了其他名称。主机操作系统已知的名称在pathconf_names
字典中给出。
所以我可以获取并检查pathconf_names
;
>>> import os
>>> print os.pathconf_names
{'PC_MAX_INPUT': 3, 'PC_VDISABLE': 9, 'PC_SYNC_IO': 25,
'PC_NAME_MAX': 4, 'PC_MAX_CANON': 2, 'PC_PRIO_IO': 19,
'PC_CHOWN_RESTRICTED': 7, 'PC_ASYNC_IO': 17, 'PC_NO_TRUNC': 8,
'PC_FILESIZEBITS': 18, 'PC_LINK_MAX': 1, 'PC_PIPE_BUF': 6,
'PC_PATH_MAX': 5}
并猜测这些标签的含义。但是我会去哪里查找他们精确的语义?标签明确特定于此界面;搜索PC_LINK_MAX
会显示documentation for a similar interface in z/OS(sic!) 1 以及日语中的Ruby等页面,但没有具体关于Python或某些平台定义的其他内容姓名以及#34;也许意味着。这篇TutorialsPoint文章是关于Python的:http://www.tutorialspoint.com/python/os_pathconf.htm,但它只是一个教程。
我在哪里可以找到这个界面的有用文档,特别是Python在各种平台上可用的标签,以及它们的值是什么意思?
(Python文档说"可用性:Unix"因此显然在某种程度上限制了可能的平台集。澄清什么"某些平台"在这里意味着将是一个很好的奖励。 )
答案 0 :(得分:4)
_PC_LINK_MAX 会返回指向该文件的最大链接数。如果fd或path引用目录,则该值适用于整个目录 目录。相应的宏是_POSIX_LINK_MAX。
_PC_MAX_CANON 返回格式化输入行的最大长度,其中fd或path必须引用终端。相应的宏是 _POSIX_MAX_CANON。
- _PC_MAX_INPUT 返回输入行的最大长度,其中fd或path必须引用终端。相应的宏是 _POSIX_MAX_INPUT。
- _PC_NAME_MAX 返回允许进程创建的目录路径或fd中文件名的最大长度。相应的 宏是_POSIX_NAME_MAX。
当路径或fd是当前工作目录时,- _PC_PATH_MAX 返回相对路径名的最大长度。相应的宏 是_POSIX_PATH_MAX。
- _PC_PIPE_BUF 返回管道缓冲区的大小,其中fd必须引用管道或FIFO,路径必须引用FIFO。相应的 宏是_POSIX_PIPE_BUF。
如果chown(2)调用可能未在此文件上使用,则- _PC_CHOWN_RESTRICTED 返回非零值。如果fd或path引用目录,那么这个 适用于该目录中的所有文件。相应的宏是 _POSIX_CHOWN_RESTRICTED。
如果访问的文件名长于_POSIX_NAME_MAX,则- _PC_NO_TRUNC 会返回非零值。相应的宏是_POSIX_NO_TRUNC。
如果可以禁用特殊字符处理,则- _PC_VDISABLE 返回非零值,其中fd或path必须引用终端。
_PC_LINK_MAX
The maximum file link count.
_PC_MAX_CANON
The maximum number of bytes in terminal canonical input line.
_PC_MAX_INPUT
The minimum maximum number of bytes for which space is available
in a terminal input queue.
_PC_NAME_MAX
The maximum number of bytes in a file name.
_PC_PATH_MAX
The maximum number of bytes in a pathname.
_PC_PIPE_BUF
The maximum number of bytes which will be written atomically to a
pipe.
_PC_CHOWN_RESTRICTED
Return 1 if appropriate privilege is required for the chown(2)
system call, otherwise 0. IEEE Std 1003.1-2001 (``POSIX.1'')
requires appropriate privilege in all cases, but this behavior
was optional in prior editions of the standard.
_PC_NO_TRUNC
Return greater than zero if attempts to use pathname components
longer than {NAME_MAX} will result in an [ENAMETOOLONG] error;
otherwise, such components will be truncated to {NAME_MAX}. IEEE
Std 1003.1-2001 (``POSIX.1'') requires the error in all cases,
but this behavior was optional in prior editions of the standard,
and some non-POSIX-compliant file systems do not support this
behavior.
_PC_VDISABLE
Returns the terminal character disabling value.
_PC_ASYNC_IO
Return 1 if asynchronous I/O is supported, otherwise 0.
_PC_PRIO_IO
Returns 1 if prioritised I/O is supported for this file, other-
wise 0.
_PC_SYNC_IO
Returns 1 if synchronised I/O is supported for this file, other-
wise 0.
_PC_ALLOC_SIZE_MIN
Minimum number of bytes of storage allocated for any portion of a
file.
_PC_FILESIZEBITS
Number of bits needed to represent the maximum file size.
_PC_REC_INCR_XFER_SIZE
Recommended increment for file transfer sizes between
_PC_REC_MIN_XFER_SIZE and _PC_REC_MAX_XFER_SIZE.
_PC_REC_MAX_XFER_SIZE
Maximum recommended file transfer size.
_PC_REC_MIN_XFER_SIZE
Minimum recommended file transfer size.
_PC_REC_XFER_ALIGN
Recommended file transfer buffer alignment.
_PC_SYMLINK_MAX
Maximum number of bytes in a symbolic link.
_PC_ACL_EXTENDED
Returns 1 if an Access Control List (ACL) can be set on the spec-
ified file, otherwise 0.
_PC_ACL_NFS4
Returns 1 if an NFSv4 ACLs can be set on the specified file, oth-
erwise 0.
_PC_ACL_PATH_MAX
Maximum number of ACL entries per file.
_PC_CAP_PRESENT
Returns 1 if a capability state can be set on the specified file,
otherwise 0.
_PC_INF_PRESENT
Returns 1 if an information label can be set on the specified
file, otherwise 0.
_PC_MAC_PRESENT
Returns 1 if a Mandatory Access Control (MAC) label can be set on
the specified file, otherwise 0.
_PC_MIN_HOLE_SIZE
If a file system supports the reporting of holes (see lseek(2)),
pathconf() and fpathconf() return a positive number that repre-
sents the minimum hole size returned in bytes. The offsets of
holes returned will be aligned to this same value. A special
value of 1 is returned if the file system does not specify the
minimum hole size but still reports holes.