diff options
author | Ron Yorston <rmy@pobox.com> | 2019-03-30 11:30:20 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-03-30 11:56:56 +0000 |
commit | be2949717934c19890879cf2a8fc74c5da55d1c7 (patch) | |
tree | 3207e0b18137525309787e0fa9e7a732f04983b7 /win32 | |
parent | 077d4c21c0e48e495bc86ea0dec28e5a7143efa8 (diff) | |
download | busybox-w32-be2949717934c19890879cf2a8fc74c5da55d1c7.tar.gz busybox-w32-be2949717934c19890879cf2a8fc74c5da55d1c7.tar.bz2 busybox-w32-be2949717934c19890879cf2a8fc74c5da55d1c7.zip |
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.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 12 |
1 files changed, 12 insertions, 0 deletions
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) | |||
1700 | } | 1700 | } |
1701 | bb_perror_msg_and_die("can't open '%s'", path); | 1701 | bb_perror_msg_and_die("can't open '%s'", path); |
1702 | } | 1702 | } |
1703 | |||
1704 | char *get_drive_cwd(const char *path, char *buffer, int size) | ||
1705 | { | ||
1706 | char drive[3] = { *path, ':', '\0' }; | ||
1707 | DWORD ret; | ||
1708 | |||
1709 | ret = GetFullPathName(drive, size, buffer, NULL); | ||
1710 | if (ret == 0 || ret > size) | ||
1711 | return NULL; | ||
1712 | bs_to_slash(buffer); | ||
1713 | return buffer; | ||
1714 | } | ||