summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-05-08 16:51:47 +0200
committerKevin Wolf <kwolf@redhat.com>2012-05-10 10:32:12 +0200
commitf53f4da9c68941fe70a3ca9e3fc792c8acf69c0c (patch)
tree4916e2b57b84b7a6560d6569e81d0dc96b371f99 /block.c
parentfa4478d5c8b74a5f0c8b93cc00590ec007be5016 (diff)
block: simplify path_is_absolute
On Windows, all the logic is already in is_windows_drive and is_windows_drive_prefix. On POSIX, there is no need to look out for colons. The win32 code changes the behaviour in some cases, we could have something like "d:foo.img". The old code would treat it as relative path, the new one as absolute. Now the path is absolute, because to go from c:/program files/blah to d:foo.img you cannot say c:/program files/blah/d:foo.img. You have to say d:foo.img. But you could also say it's relative because (I think, at least it was like that in DOS 15 years ago) d:foo.img is relative to the current path of drive D. Considering how path_is_absolute is used by path_combine, I think it's better to treat it as absolute. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/block.c b/block.c
index 2978135469..0fb188f763 100644
--- a/block.c
+++ b/block.c
@@ -210,21 +210,14 @@ static int path_has_protocol(const char *path)
int path_is_absolute(const char *path)
{
- const char *p;
#ifdef _WIN32
/* specific case for names like: "\\.\d:" */
- if (*path == '/' || *path == '\\')
+ if (is_windows_drive(path) || is_windows_drive_prefix(path)) {
return 1;
-#endif
- p = strchr(path, ':');
- if (p)
- p++;
- else
- p = path;
-#ifdef _WIN32
- return (*p == '/' || *p == '\\');
+ }
+ return (*path == '/' || *path == '\\');
#else
- return (*p == '/');
+ return (*path == '/');
#endif
}