Mercurial > hg > xemacs-beta
diff src/realpath.c @ 195:a2f645c6b9f8 r20-3b24
Import from CVS: tag r20-3b24
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:59:05 +0200 |
parents | 376386a54a3c |
children | 850242ba4a81 |
line wrap: on
line diff
--- a/src/realpath.c Mon Aug 13 09:58:32 2007 +0200 +++ b/src/realpath.c Mon Aug 13 09:59:05 2007 +0200 @@ -77,6 +77,49 @@ strcpy(copy_path, path); path = copy_path; max_path = copy_path + PATH_MAX - 2; +#ifdef WINDOWSNT + /* + ** In NT we have two different cases: (1) the path name begins + ** with a drive letter, e.g., "C:"; and (2) the path name begins + ** with just a slash, which roots to the current drive. In the + ** first case we are going to leave things alone, in the second + ** case we will prepend the drive letter to the given path. + ** Note: So far in testing, I'm only seeing case #1, even though + ** I've tried to get the other cases to happen. + ** August Hill, 31 Aug 1997. + ** + ** Check for a driver letter...C:/... + */ + if (*(path + 1) == ':') + { + strncpy(new_path, path, 3); + new_path += 3; + path += 3; + } + + /* + ** No drive letter, but a beginning slash? Prepend the drive + ** letter... + */ + else if (*path == '/') + { + getcwd(new_path, PATH_MAX - 1); + new_path += 3; + path++; + } + + /* + ** Just a path name, prepend the current directory + */ + else + { + getcwd(new_path, PATH_MAX - 1); + new_path += strlen(new_path); + if (new_path[-1] != '/') + *new_path++ = '/'; + } + +#else /* If it's a relative pathname use getwd for starters. */ if (*path != '/') { @@ -94,7 +137,7 @@ *new_path++ = '/'; path++; } - +#endif /* Expand each slash-separated pathname component. */ while (*path != '\0') {