diff options
author | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2011-01-03 02:22:12 -0500 |
---|---|---|
committer | Michihiro NAKAJIMA <ggcueroad@gmail.com> | 2011-01-03 02:22:12 -0500 |
commit | 96725b79460a0220619ef81d3751a089fa5b76c7 (patch) | |
tree | f27d055580c5e6509296e26e00946d4815a612ef /tar/util.c | |
parent | 055f150d0de491c646906f575438ad492f134252 (diff) | |
download | libarchive-96725b79460a0220619ef81d3751a089fa5b76c7.tar.gz |
Correctly detect Windows full paths.
SVN-Revision: 2854
Diffstat (limited to 'tar/util.c')
-rw-r--r-- | tar/util.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -263,12 +263,19 @@ yes(const char *fmt, ...) * about -C with non-existent directories; such requests will only * fail if the directory must be accessed. * - * TODO: Make this handle Windows paths correctly. */ void set_chdir(struct bsdtar *bsdtar, const char *newdir) { +#if defined(_WIN32) && !defined(__CYGWIN__) + if (newdir[0] == '/' || newdir[0] == '\\' || + /* Detect this type, for example, "C:\" or "C:/" */ + (((newdir[0] >= 'a' && newdir[0] <= 'z') || + (newdir[0] >= 'A' && newdir[0] <= 'Z')) && + newdir[1] == ':' && (newdir[2] == '/' || newdir[2] == '\\'))) { +#else if (newdir[0] == '/') { +#endif /* The -C /foo -C /bar case; dump first one. */ free(bsdtar->pending_chdir); bsdtar->pending_chdir = NULL; |