changeset 260:e320dc29bfcd

Rewrote abs_path() so the code will work on NT 4.0.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 23 Feb 2003 06:35:18 +0000
parents 22a215209887
children 3087f7da0515
files win/dirent.c
diffstat 1 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/win/dirent.c	Thu Feb 20 23:43:44 2003 +0000
+++ b/win/dirent.c	Sun Feb 23 06:35:18 2003 +0000
@@ -56,24 +56,32 @@
 	return cache [unit] = r;
 }
 
-char *
-abs_path(const char *name, char *buffer, int len)
+char *abs_path(const char *name, char *buffer, int len)
 {
-	char buf[4];
-	if (isalpha(name[0]) && name[1] == ':' && name[2] == '\0') {
-		buf[0] = name[0];
-		buf[1] = name[1];
-		buf[2] = '.';
-		buf[3] = '\0';
-		name = buf;
+	char *buf;
+	LPTSTR file;
+
+	if(isalpha(name[0]) && name[1] == ':' && name[2] == '\0')
+	{
+		int drive = _getdrive();
+		char newdrive = toupper(name[0]);
+
+		_chdrive((newdrive - 'A')+1);
+
+		if(getcwd(buffer, len))
+		{
+			_chdrive(drive);
+			return buffer;
+		}
+		_chdrive(drive);
+		return NULL;
 	}
-	if (GetLongPathName(name, buffer, len))
-		return NULL;
-	return buffer;
+	if(GetFullPathName(name, len, buffer, &file))
+		return buffer;
+	return NULL;
 }
 
-DIR *
-openxdir(const char *path, unsigned att_mask)
+DIR *openxdir(const char *path, unsigned att_mask)
 {
 	DIR *dir;
 	char name[MAXPATHLEN+3];