diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c index e0654e9275bf9caa88334be60f4c87ac74c0b52d..463cc6208999d782261cf9da5b5146e802a8fc10 100644 --- a/src/xpdev/dirwrap.c +++ b/src/xpdev/dirwrap.c @@ -119,24 +119,19 @@ void DLLCALL _splitpath(const char *path, char *drive, char *dir, char *fname, c char* p; ext[0]=0; - drive[0]=0; /* no drive letters on Unix */ - - strcpy(dir,path); - p=strrchr(dir,'/'); - if(p==NULL) - p=strrchr(dir,'\\'); - if(p==NULL) { - p=(char*)path; - dir[0]=0; - } else { - *p=0; /* truncate dir */ - p++; - } - strcpy(fname,p); - p=strrchr(fname,'.'); + drive[0]=0; /* no drive letters on Unix */ + + strcpy(dir,path); /* Optional directory path, including trailing slash. */ + p=getfname(dir); + strcpy(fname,p); /* Base filename (no extension) */ + if(p==dir) + dir[0]=0; /* no directory specified in path */ + else + *p=0; /* truncate dir at filename */ + p=getfext(fname); if(p!=NULL) { + strcpy(ext,p); /* Optional filename extension, including leading period (.) */ *p=0; - strcpy(ext,p+1); } } #endif