X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fish%2Ffish.c;h=f6996032b889ca03431fa7ceea143adcb2091b68;hb=refs%2Ftags%2F1.0.75;hp=3300536d05d30953364dfad3f99ea4113b63ae1e;hpb=6a14f1c2502f58ff7bed8cb451f95a83f5ee920a;p=libguestfs.git diff --git a/fish/fish.c b/fish/fish.c index 3300536..f699603 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -1295,3 +1295,51 @@ xwrite (int fd, const void *v_buf, size_t len) return 0; } + +/* Resolve the special "win:..." form for Windows-specific paths. + * This always returns a newly allocated string which is freed by the + * caller function in "cmds.c". + */ +char * +resolve_win_path (const char *path) +{ + char *ret; + size_t i; + + if (strncasecmp (path, "win:", 4) != 0) { + ret = strdup (path); + if (ret == NULL) + perror ("strdup"); + return ret; + } + + path += 4; + + /* Drop drive letter, if it's "C:". */ + if (strncasecmp (path, "c:", 2) == 0) + path += 2; + + if (!*path) { + ret = strdup ("/"); + if (ret == NULL) + perror ("strdup"); + return ret; + } + + ret = strdup (path); + if (ret == NULL) { + perror ("strdup"); + return NULL; + } + + /* Blindly convert any backslashes into forward slashes. Is this good? */ + for (i = 0; i < strlen (ret); ++i) + if (ret[i] == '\\') + ret[i] = '/'; + + char *t = guestfs_case_sensitive_path (g, ret); + free (ret); + ret = t; + + return ret; +}