gpt4 book ai didi

python - os.pathconf() 键及其含义

转载 作者:行者123 更新时间:2023-11-28 22:37:28 25 4
gpt4 key购买 nike

documentation for os.pathconf() (或与 Python 2 相同)仅含糊地暗示一组键,其含义在其他各个地方指定;

Return system configuration information relevant to a named file. name specifies the configuration value to retrieve; it may be a string which is the name of a defined system value; these names are specified in a number of standards (POSIX.1, Unix 95, Unix 98, and others). Some platforms define additional names as well. The names known to the host operating system are given in the pathconf_names dictionary.

所以我可以获取并检查 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}

然后猜猜其中一些标签的含义。但是我该去哪里查找它们的精确语义呢?标签显然是特定于此接口(interface)的;搜索 PC_LINK_MAX 会出现 documentation for a similar interface in z/OS (原文如此!)1 和用于 Ruby 等的日文页面,但与 Python 或“某些平台也定义其他名称”的含义无关。这篇 TutorialsPoint 文章是关于 Python 的:http://www.tutorialspoint.com/python/os_pathconf.htm但这只是一个教程。

我在哪里可以找到有关此接口(interface)的有用文档,特别是关于 Python 在各种平台上可用的标签及其值的含义?

(Python 文档说“可用性:Unix”,因此这显然在某种程度上限制了可能的平台集。在这里澄清“某些平台”的含义将是一个不错的奖励。)


  1. IBM 甚至比 Microsoft 还运行一个链接机器人,它会在注意到任何人链接到的任何内容时立即转移;所以这个 URL 现在不太可能再工作了。对不起。

最佳答案

来自pathconf manual (Linux) :

  • _PC_LINK_MAX returns the maximum number of links to the file. If fd or path refer to a directory, then the value applies to the whole directory. The corresponding macro is _POSIX_LINK_MAX.

  • _PC_MAX_CANON returns the maximum length of a formatted input line, where fd or path must refer to a terminal. The corresponding macro is _POSIX_MAX_CANON.

  • _PC_MAX_INPUT returns the maximum length of an input line, where fd or path must refer to a terminal. The corresponding macro is _POSIX_MAX_INPUT.
  • _PC_NAME_MAX returns the maximum length of a filename in the directory path or fd that the process is allowed to create. The corresponding macro is _POSIX_NAME_MAX.
  • _PC_PATH_MAX returns the maximum length of a relative pathname when path or fd is the current working directory. The corresponding macro is _POSIX_PATH_MAX.
  • _PC_PIPE_BUF returns the size of the pipe buffer, where fd must refer to a pipe or FIFO and path must refer to a FIFO. The corresponding macro is _POSIX_PIPE_BUF.
  • _PC_CHOWN_RESTRICTED returns nonzero if the chown(2) call may not be used on this file. If fd or path refer to a directory, then this applies to all files in that directory. The corresponding macro is _POSIX_CHOWN_RESTRICTED.
  • _PC_NO_TRUNC returns nonzero if accessing filenames longer than _POSIX_NAME_MAX generates an error. The corresponding macro is _POSIX_NO_TRUNC.
  • _PC_VDISABLE returns nonzero if special character processing can be disabled, where fd or path must refer to a terminal.

来自pathconf manual (FreeBSD) :

 _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.

关于python - os.pathconf() 键及其含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36563795/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com