diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c index a785204c6df18f2f2cc5ff3d0f2e7cbf558d96db..14dddaed5d88912dbb65916a07cbf3bd6ebf0e6e 100644 --- a/src/xpdev/dirwrap.c +++ b/src/xpdev/dirwrap.c @@ -88,11 +88,43 @@ char* DLLCALL getfname(char* path) return(fname); } -#if !defined(__unix__) + +/****************************************************************************/ +/* Break a path name into components. */ +/****************************************************************************/ +#if defined(__unix__) +void DLLCALL _splitpath(const char *path, char *drive, char *dir, char *fname, char *ext) +{ + 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=path; + dir[0]=0; + } else { + *p=0; /* truncate dir */ + p++; + } + strcpy(fname,p); + p=strrchr(fname,'.'); + if(p!=NULL) { + *p=0; + strcpy(ext,p+1); + } +} +#endif + /****************************************************************************/ /* Win32 (minimal) implementation of POSIX.2 glob() function */ /* This code _may_ work on other DOS-based platforms (e.g. OS/2) */ /****************************************************************************/ +#if !defined(__unix__) static int glob_compare( const void *arg1, const void *arg2 ) { /* Compare all of both strings: */ diff --git a/src/xpdev/dirwrap.h b/src/xpdev/dirwrap.h index 2a111c2e65dc282ca060a7495c80484ae56bed2d..5746666316b9e03d0b3cdc2400c8e008d55b825b 100644 --- a/src/xpdev/dirwrap.h +++ b/src/xpdev/dirwrap.h @@ -170,6 +170,11 @@ DLLEXPORT char* DLLCALL getfname(char* path); DLLEXPORT int DLLCALL getfattr(char* filename); DLLEXPORT ulong DLLCALL getfreediskspace(char* path); +#if defined(__unix__) +DLLEXPORT void DLLCALL _splitpath(const char *path, char *drive, char *dir, + char *fname, char *ext); +#endif + #if defined(__cplusplus) } #endif