Commit 3972ee78 authored by rswindell's avatar rswindell
Browse files

Changed BACKSLASH macro to (unbiased) PATH_DELIM.

Created IS_PATH_DELIM() macro (stole websrvr.c->is_slash macro).
Defines BSD _PATH_TMP and _PATH_DEVNULL macros for all platforms.
parent 7b7a9711
......@@ -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);
......
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment