本文介绍了PATH_MAX 和 NAME_MAX 有什么关系,如何获取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

limits.h 中以及POSIX联机帮助页的不同位置,都有对 PATH_MAX NAME_MAX 的引用.它们之间如何相互联系?他们的官方文件在哪里?如何在运行时获取它们,以及如何在C,Python和GNU(shell)环境下编译(在相关时)?

In limits.h, and in various places in the POSIX manpages, there are references to PATH_MAX and NAME_MAX.How do these relate to one another?Where is the official documentation for them?How can I obtain them at run time, and (where relevant) compile time for the C, Python, and GNU (shell) environments?

推荐答案

PATH_MAX 是文件系统路径的最大长度. NAME_MAX 是文件名的最大长度(在特定位置).因此,/foo/bar PATH_MAX 的限制,只有 bar 部分的长度受 NAME_MAX 的限制

PATH_MAX is the maximum length of a filesystem path. NAME_MAX is the maximum length of a filename (in a particular spot). So, /foo/bar is restricted by PATH_MAX, and only the bar portion has its length limited by NAME_MAX.

您可以在运行时通过 pathconf _PC_PATH_MAX _PC_NAME_MAX 来获取这些文件,尽管标准做法通常只是使用静态宏在编译时.我想最好使用运行时选项,因为这样可以潜在地支持更长的值,但是我不确定是什么系统(如果有的话)实际上提供了 pathconf 的返回值,即大于 POSIX_FOO_MAX 值的值.

You can get these at run time via pathconf, as _PC_PATH_MAX and _PC_NAME_MAX, although standard practice is generally just to use the static macros at compile time. I suppose it would be better to use the run-time option because you could potentially support longer values that way, but I'm not sure what (if any) systems actually provide a return from pathconf which is greater than the value of the POSIX_FOO_MAX values.

这篇关于PATH_MAX 和 NAME_MAX 有什么关系,如何获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 18:56