From be2949717934c19890879cf2a8fc74c5da55d1c7 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 30 Mar 2019 11:30:20 +0000 Subject: win32: improved support for c:path path names Microsoft Windows permits path names of the form 'c:path', without a path separator after the colon. The system records a current directory for each drive and the path is interpreted relative to that. Since Windows API calls understand 'c:path' path names many commands in busybox-w32 already work with them. This commit adds the following: - The 'cd' shell built-in interprets 'c:path' path names correctly. Previously it treated them as relative to the shell's concept of the current working directory, not the current directory of the specified drive. - The 'pwd' shell built-in takes the '-a' option to list the current directory for all drives. - 'c:path' path names are subject to tab-completion. Paths of the form 'c:path' don't work for mapped network drives or paths that have been associated with a drive using SUBST. See GitHub issue #147. --- win32/mingw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index 1d5644f92..ec7d6c456 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1700,3 +1700,15 @@ char *xabsolute_path(char *path) } bb_perror_msg_and_die("can't open '%s'", path); } + +char *get_drive_cwd(const char *path, char *buffer, int size) +{ + char drive[3] = { *path, ':', '\0' }; + DWORD ret; + + ret = GetFullPathName(drive, size, buffer, NULL); + if (ret == 0 || ret > size) + return NULL; + bs_to_slash(buffer); + return buffer; +} -- cgit v1.2.3-55-g6feb