summaryrefslogtreecommitdiff
path: root/tar/util.c
diff options
context:
space:
mode:
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>2011-01-03 02:22:12 -0500
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>2011-01-03 02:22:12 -0500
commit96725b79460a0220619ef81d3751a089fa5b76c7 (patch)
treef27d055580c5e6509296e26e00946d4815a612ef /tar/util.c
parent055f150d0de491c646906f575438ad492f134252 (diff)
downloadlibarchive-96725b79460a0220619ef81d3751a089fa5b76c7.tar.gz
Correctly detect Windows full paths.
SVN-Revision: 2854
Diffstat (limited to 'tar/util.c')
-rw-r--r--tar/util.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tar/util.c b/tar/util.c
index c02bb37a..42e10e45 100644
--- a/tar/util.c
+++ b/tar/util.c
@@ -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;