From 567c2ddfab92fef92d42a66e0d2e7537ceab534c Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sat, 18 Oct 2003 07:55:06 +0000
Subject: [PATCH] Fixed Unix _splitpath() to more closely mimic Win32 behavior:
 trailing slashes included in directory and '.' included in extensions.

---
 src/xpdev/dirwrap.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c
index e0654e9275..463cc62089 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
-- 
GitLab