From 1a315fe57e393bbafa32d5482fed052e39ffdc2e Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Fri, 23 Sep 2011 14:56:37 +0000 Subject: [PATCH] Make skdiff paths work on windows http://codereview.appspot.com/5111041/ git-svn-id: http://skia.googlecode.com/svn/trunk@2321 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/skdiff_main.cpp | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp index a024a7662..04b0dc01f 100644 --- a/tools/skdiff_main.cpp +++ b/tools/skdiff_main.cpp @@ -32,6 +32,14 @@ * images into the second directory, also writing index.html there. */ +#if SK_BUILD_FOR_WIN32 + #define PATH_DIV_STR "\\" + #define PATH_DIV_CHAR '\\' +#else + #define PATH_DIV_STR "/" + #define PATH_DIV_CHAR '/' +#endif + struct DiffRecord { DiffRecord (const SkString filename, const SkString basePath, @@ -481,8 +489,8 @@ static void analyze_chromium(DiffMetricProc dmp, } SkString fullname (dirname); fullname.append(newdirname); - if (!fullname.endsWith("/")) { - fullname.append("/"); + if (!fullname.endsWith(PATH_DIV_STR)) { + fullname.append(PATH_DIV_STR); } analyze_chromium(dmp, colorThreshold, differences, fullname, outputDir, summary); @@ -610,8 +618,8 @@ static void print_diff_page (const int matchCount, unsigned int ui; SkString relativePath; for (ui = 0; ui < outputDir.size(); ui++) { - if (outputDir[ui] == '/') { - relativePath.append("../"); + if (outputDir[ui] == PATH_DIV_CHAR) { + relativePath.append(".." PATH_DIV_STR); } } @@ -625,10 +633,10 @@ static void print_diff_page (const int matchCount, if (0 == diff->fFractionDifference) { continue; } - if (!diff->fBasePath.startsWith("/")) { + if (!diff->fBasePath.startsWith(PATH_DIV_STR)) { diff->fBasePath.prepend(relativePath); } - if (!diff->fComparisonPath.startsWith("/")) { + if (!diff->fComparisonPath.startsWith(PATH_DIV_STR)) { diff->fComparisonPath.prepend(relativePath); } int height = compute_image_height(diff->fBaseHeight, diff->fBaseWidth); @@ -764,25 +772,25 @@ int main (int argc, char ** argv) { return 0; } - if (!baseDir.endsWith("/")) { - baseDir.append("/"); + if (!baseDir.endsWith(PATH_DIV_STR)) { + baseDir.append(PATH_DIV_STR); } - if (!comparisonDir.endsWith("/")) { - comparisonDir.append("/"); + if (!comparisonDir.endsWith(PATH_DIV_STR)) { + comparisonDir.append(PATH_DIV_STR); } - if (!outputDir.endsWith("/")) { - outputDir.append("/"); + if (!outputDir.endsWith(PATH_DIV_STR)) { + outputDir.append(PATH_DIV_STR); } if (analyzeChromium) { - baseDir.append("webkit/"); + baseDir.append("webkit" PATH_DIV_STR); if (chromiumRelease) { - baseDir.append("Release/"); + baseDir.append("Release" PATH_DIV_STR); } if (chromiumDebug) { - baseDir.append("Debug/"); + baseDir.append("Debug" PATH_DIV_STR); } - baseDir.append("layout-test-results/"); + baseDir.append("layout-test-results" PATH_DIV_STR); analyze_chromium(diffProc, colorThreshold, &differences, baseDir, outputDir, &summary); } else {