Codebase list grafx2 / 5b87fdd
Import Upstream version 2.5+git20181211 Gürkan Myczko authored 4 years ago root committed 4 years ago
1 changed file(s) with 16 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
2424 // the path. So this implementation is limited, it's really better to
2525 // use realpath() if your platform has it.
2626
27 #if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(__amigaos__)
27 #if !defined(PATH_MAX)
2828 // This is a random default value ...
29 #define PATH_MAX 32768
29 #define PATH_MAX 4096
3030 #endif
3131
3232 static char *sep(char *path)
122122 return _fullpath(resolved_path,_path,260);
123123 }
124124 #else
125 #include <limits.h>
125
126126 // Use the stdlib function.
127127 char *Realpath(const char *_path, char *resolved_path)
128128 {
129 // While linux version of realpath handles the resolved_path being a
130 // null pointer, this is not the case for other platforms (Haiku), nor
131 // specified by the open group in POSIX. So, be safe and allocate
132 // ourselves.
133 if(resolved_path==NULL) // if we called realpath with null as a 2nd arg
134 resolved_path = (char*) malloc( PATH_MAX );
135 return realpath(_path, resolved_path);
129 /// POSIX 2004 states :
130 /// If resolved_name is a null pointer, the behavior of realpath()
131 /// is implementation-defined.
132 ///
133 /// but POSIX 2008 :
134 /// If resolved_name is a null pointer, the generated pathname shall
135 /// be stored as a null-terminated string in a buffer allocated as if
136 /// by a call to malloc().
137 ///
138 /// So we assume all platforms now support passing NULL.
139 /// If you find a platform where this is not the case,
140 /// please add a new implementation with #ifdef's.
141 return realpath(_path, resolved_path);
136142 }
137143 #endif
138
139