diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c index bb8985ea76fe0185848e4a77146357fc0bbfa429..1054ff8c51ae76f39329ce089cefdc6e44daa213 100644 --- a/src/xpdev/dirwrap.c +++ b/src/xpdev/dirwrap.c @@ -513,7 +513,7 @@ BOOL DLLCALL isdir(const char *filename) SAFECOPY(path,filename); p=lastchar(path); - if(p!=path && (*p=='/' || *p==BACKSLASH)) { /* chop off trailing slash */ + if(p!=path && IS_PATH_DELIM(*p)) { /* chop off trailing slash */ #if !defined(__unix__) if(*(p-1)!=':') /* Don't change C:\ to C: */ #endif @@ -564,8 +564,8 @@ ulong DLLCALL delfiles(char *inpath, char *spec) glob_t g; lastch=*lastchar(inpath); - if(lastch!='/' && lastch!='\\') - sprintf(path,"%s%c",inpath,BACKSLASH); + if(!IS_PATH_DELIM(lastch)) + sprintf(path,"%s%c",inpath,PATH_DELIM); else strcpy(path,inpath); strcat(path,spec); @@ -734,7 +734,7 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) { #endif /****************************************************************************/ -/* Adds a trailing slash/backslash on path strings */ +/* Adds a trailing slash/backslash (path delimiter) on path strings */ /****************************************************************************/ char* DLLCALL backslash(char* path) { @@ -743,7 +743,7 @@ char* DLLCALL backslash(char* path) p=lastchar(path); if(*p!='/' && *p!='\\') { - *(++p)=BACKSLASH; + *(++p)=PATH_DELIM; *(++p)=0; } return(path); diff --git a/src/xpdev/dirwrap.h b/src/xpdev/dirwrap.h index 135f6b2c7dab9a2964f779cf966a98c9e6ecb931..f93051faae7a683e80f33e44d037186f0e2eaf78 100644 --- a/src/xpdev/dirwrap.h +++ b/src/xpdev/dirwrap.h @@ -158,9 +158,24 @@ extern "C" { #endif #if defined(__unix__) - #define BACKSLASH '/' + #define PATH_DELIM '/' + #define IS_PATH_DELIM(x) (x=='/') + + /* These may be pre-defined in paths.h (BSD) */ + #ifndef _PATH_TMP + #define _PATH_TMP "/tmp/" + #endif + #ifndef _PATH_DEVNULL + #define _PATH_DEVNULL "/dev/null" + #endif + #else /* MS-DOS based OS */ - #define BACKSLASH '\\' + + #define PATH_DELIM '\\' + #define IS_PATH_DELIM(x) ((x)=='/' || (x)=='\\') + #define _PATH_TMP getenv("TEMP") + #define _PATH_DEVNULL "NUL" + #endif #if !defined(MAX_PATH) /* maximum path length */