diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-08 13:47:39 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-08 13:47:39 +0000 |
commit | 21ecba88cd7891cdf28968ad5dfd70b589f12b34 (patch) | |
tree | 975ddf29c66a746892f9e46c5941b6c41eb7d6bf /tools | |
parent | 1aad28ae1668929180a78539a2ed78890b907479 (diff) |
skdiff: clean up isPathAbsolute check for Windows
This is a followup to https://codereview.appspot.com/6458046/ ('Fix skdiff when using windows path that begins with a drive letter')
Review URL: https://codereview.appspot.com/6450106
git-svn-id: http://skia.googlecode.com/svn/trunk@5004 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r-- | tools/skdiff_main.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp index d10ebfc28d..3fc18e7ad8 100644 --- a/tools/skdiff_main.cpp +++ b/tools/skdiff_main.cpp @@ -1048,14 +1048,21 @@ static void print_diff_page (const int matchCount, // Need to convert paths from relative-to-cwd to relative-to-outputDir // FIXME this doesn't work if there are '..' inside the outputDir - bool pathFromRoot; + bool isPathAbsolute = false; + // On Windows or Linux, a path starting with PATH_DIV_CHAR is absolute. + if (outputDir.size() > 0 && PATH_DIV_CHAR == outputDir[0]) { + isPathAbsolute = true; + } #ifdef SK_BUILD_FOR_WIN32 - pathFromRoot = outputDir.size() > 1 && ':' == outputDir[1]; -#else - pathFromRoot = outputDir.size() > 0 && PATH_DIV_CHAR == outputDir[0]; + // On Windows, absolute paths can also start with "x:", where x is any + // drive letter. + if (outputDir.size() > 1 && ':' == outputDir[1]) { + isPathAbsolute = true; + } #endif + SkString relativePath; - if (!pathFromRoot) { + if (!isPathAbsolute) { unsigned int ui; for (ui = 0; ui < outputDir.size(); ui++) { if (outputDir[ui] == PATH_DIV_CHAR) { |