COOPY » Guide
version 0.6.5
|
00001 /* Define PATH_MAX somehow. Requires sys/types.h. 00002 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2012 Free Software 00003 Foundation, Inc. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2, or (at your option) 00008 any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 00017 00018 #ifndef _PATHMAX_H 00019 # define _PATHMAX_H 00020 00021 /* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, 00022 including the terminating NUL byte. 00023 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html> 00024 PATH_MAX is not defined on systems which have no limit on filename length, 00025 such as GNU/Hurd. 00026 00027 This file does *not* define PATH_MAX always. Programs that use this file 00028 can handle the GNU/Hurd case in several ways: 00029 - Either with a package-wide handling, or with a per-file handling, 00030 - Either through a 00031 #ifdef PATH_MAX 00032 or through a fallback like 00033 #ifndef PATH_MAX 00034 # define PATH_MAX 8192 00035 #endif 00036 or through a fallback like 00037 #ifndef PATH_MAX 00038 # define PATH_MAX pathconf ("/", _PC_PATH_MAX) 00039 #endif 00040 */ 00041 00042 # include <unistd.h> 00043 00044 # include <limits.h> 00045 00046 # ifndef _POSIX_PATH_MAX 00047 # define _POSIX_PATH_MAX 256 00048 # endif 00049 00050 /* Don't include sys/param.h if it already has been. */ 00051 # if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN 00052 # include <sys/param.h> 00053 # endif 00054 00055 # if !defined PATH_MAX && defined MAXPATHLEN 00056 # define PATH_MAX MAXPATHLEN 00057 # endif 00058 00059 # ifdef __hpux 00060 /* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, 00061 *not* including the terminating NUL byte, and is set to 1023. 00062 Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is 00063 not defined at all any more. */ 00064 # undef PATH_MAX 00065 # define PATH_MAX 1024 00066 # endif 00067 00068 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 00069 /* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, 00070 section "Maximum Path Length Limitation", 00071 <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath> 00072 explains that the maximum size of a filename, including the terminating 00073 NUL byte, is 260 = 3 + 256 + 1. 00074 This is the same value as 00075 - FILENAME_MAX in <stdio.h>, 00076 - _MAX_PATH in <stdlib.h>, 00077 - MAX_PATH in <windef.h>. 00078 Undefine the original value, because mingw's <limits.h> gets it wrong. */ 00079 # undef PATH_MAX 00080 # define PATH_MAX 260 00081 # endif 00082 00083 #endif /* _PATHMAX_H */