--- ray/src/common/paths.h 2003/07/03 22:41:44 2.17 +++ ray/src/common/paths.h 2012/06/29 23:09:06 2.24 @@ -1,12 +1,9 @@ -/* RCSid $Id: paths.h,v 2.17 2003/07/03 22:41:44 schorsch Exp $ */ +/* RCSid $Id: paths.h,v 2.24 2012/06/29 23:09:06 greg Exp $ */ /* * Definitions for paths on different machines */ #ifndef _RAD_PATHS_H_ #define _RAD_PATHS_H_ -#ifdef __cplusplus -extern "C" { -#endif #include #include @@ -17,17 +14,17 @@ extern "C" { #ifdef _WIN32 #include + #include /* getcwd(), chdir(), _mkdir(), etc. */ #define access _access + #define mkdir(dirname,perms) _mkdir(dirname) #define PATH_MAX _MAX_PATH + #define NULL_DEVICE "NUL" #define DIRSEP '/' - #define ISDIRSEP(c) ((c)=='/' || (c)=='\\') - #define ISABS(s) ((s)!=NULL \ - && (s[0])!='\0' \ - && ( ISDIRSEP(s[0]) \ - || ( (s[1])!='\0' \ - && (isupper(s[0])||islower(s[0])) \ - && (s[1])==':'))) + #define ISDIRSEP(c) (((c)=='/') | ((c)=='\\')) + #define ISABS(s) ( ISDIRSEP((s)[0]) \ + || ( isupper((s)[0]) | islower((s)[0]) \ + && (s)[1]==':' && ISDIRSEP((s)[2]) ) ) #define CASEDIRSEP case '/': case '\\' #define PATHSEP ';' #define CURDIR '.' @@ -41,17 +38,26 @@ extern "C" { /* only does half the work for access() */ #ifndef F_OK #define F_OK 00 - #define X_OK 01 #define W_OK 02 - #define R_OK 04 #endif + #ifndef R_OK + #define X_OK 01 + #define R_OK 04 + #endif /* to make the permissions user specific we'd need to use CreateFile() */ #ifndef S_IRUSR #define S_IRUSR _S_IREAD #define S_IWUSR _S_IWRITE #endif -extern char *fixargv0(); + #ifdef __cplusplus + extern "C" { + #endif + extern char *fixargv0(); + #ifdef __cplusplus + } + #endif + #else /* everything but Windows */ #include #include @@ -66,8 +72,9 @@ extern char *fixargv0(); #ifdef AMIGA + #define NULL_DEVICE "NIL:" #define DIRSEP '/' - #define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0]))) + #define ISABS(s) ISDIRSEP((s)[0]) #define PATHSEP ';' #define CURDIR '.' #define DEFAULT_TEMPDIRS {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL} @@ -86,11 +93,11 @@ extern char *fixargv0(); /* this is defined as _PATH_DEVNULL in /usr/include/paths.h on Linux */ #define NULL_DEVICE "/dev/null" #define DIRSEP '/' - #define ISABS(s) ((s)!=NULL && (ISDIRSEP(s[0]))) + #define ISABS(s) ISDIRSEP((s)[0]) #define PATHSEP ':' #define CURDIR '.' #define DEFAULT_TEMPDIRS {"/var/tmp", "/usr/tmp", "/tmp", ".", NULL} - #define TEMPLATE "/usr/tmp/rtXXXXXX" + #define TEMPLATE "/tmp/rtXXXXXX" #define TEMPLEN 17 #define ULIBVAR "RAYPATH" #ifndef DEFPATH @@ -108,6 +115,9 @@ extern char *fixargv0(); #define CASEDIRSEP case DIRSEP #endif +#ifdef __cplusplus +extern "C" { +#endif /* Find a writeable directory for temporary files */ /* If s is NULL, we return a static string */