aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skimage_main.cpp
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-24 18:12:17 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-24 18:12:17 +0000
commit1bee03704408fad8df334f6193267774bb21231b (patch)
tree7f7689554bbfc640da7150bb7fa14f62bc06d78b /tools/skimage_main.cpp
parent7070f76b90b098b4713bc0d13dc129adea64d7ef (diff)
Add path utils, plus a test for it.
SkOSFile: Added class SkOSPath with functions for modifying strings representing path names. OSPathTest.cpp: Test of the new utilities. factory.cpp: Use SkPathJoin. gmmain and gm_expectations: Use SkOSPath::SkPathJoin instead of a local version. skimage_main.cpp: Use the new location of SkPathJoin and SkBasename. R=epoger@google.com Review URL: https://codereview.chromium.org/15747004 git-svn-id: http://skia.googlecode.com/svn/trunk@9277 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/skimage_main.cpp')
-rw-r--r--tools/skimage_main.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp
index f52cf32217..98cde5044c 100644
--- a/tools/skimage_main.cpp
+++ b/tools/skimage_main.cpp
@@ -69,27 +69,10 @@ static SkImageDecoder::Format guess_format_from_suffix(const char suffix[]) {
return SkImageDecoder::kUnknown_Format;
}
-/**
- * Return the name of the file, ignoring the directory structure.
- * Does not create a new string.
- * @param fullPath Full path to the file.
- * @return string The basename of the file - anything beyond the final slash, or the full name
- * if there is no slash.
- * TODO: Might this be useful as a utility function in SkOSFile? Would it be more appropriate to
- * create a new string?
- */
-static const char* SkBasename(const char* fullPath) {
- const char* filename = strrchr(fullPath, SkPATH_SEPARATOR);
- if (NULL == filename || *++filename == '\0') {
- filename = fullPath;
- }
- return filename;
-}
-
static void make_outname(SkString* dst, const char outDir[], const char src[],
const char suffix[]) {
- const char* basename = SkBasename(src);
- dst->set(skiagm::SkPathJoin(outDir, basename));
+ SkString basename = SkOSPath::SkBasename(src);
+ dst->set(SkOSPath::SkPathJoin(outDir, basename.c_str()));
if (!dst->endsWith(suffix)) {
const char* cstyleDst = dst->c_str();
const char* dot = strrchr(cstyleDst, '.');
@@ -272,8 +255,7 @@ static bool write_subset(const char* writePath, const char* filename, const char
SkASSERT(bitmapFromDecodeSubset != NULL);
// Create a subdirectory to hold the results of decodeSubset.
- // TODO: Move SkPathJoin into SkOSFile.h
- SkString dir = skiagm::SkPathJoin(writePath, "subsets");
+ SkString dir = SkOSPath::SkPathJoin(writePath, "subsets");
if (!sk_mkdir(dir.c_str())) {
gFailedSubsetDecodes.push_back().printf("Successfully decoded %s from %s, but failed to "
"create a directory to write to.", subsetDim,
@@ -298,7 +280,7 @@ static bool write_subset(const char* writePath, const char* filename, const char
return false;
}
- SkString dirExtracted = skiagm::SkPathJoin(writePath, "extracted");
+ SkString dirExtracted = SkOSPath::SkPathJoin(writePath, "extracted");
if (!sk_mkdir(dirExtracted.c_str())) {
gFailedSubsetDecodes.push_back().printf("Successfully decoded %s from %s, but failed to "
"create a directory for extractSubset comparison.",
@@ -335,7 +317,8 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath)
}
// Create a string representing just the filename itself, for use in json expectations.
- const char* filename = SkBasename(srcPath);
+ SkString basename = SkOSPath::SkBasename(srcPath);
+ const char* filename = basename.c_str();
if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures)) {
gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.width(),