diff options
author | tfarina <tfarina@chromium.org> | 2014-07-28 19:26:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-28 19:26:58 -0700 |
commit | a8e2e1504b9af6ba791637f228debaa23953064a (patch) | |
tree | c4dc50d10bb27a4bfd263f877cb7d602f6779afc | |
parent | 2bff230d835fbc84f0ce8b2e7a399fe8416ec7c8 (diff) |
Cleanup: Rename SkOSPath functions.
Mostly for brevity and matches better with Python:
Python | Old C++ | New C++
os.path.join | SkOSPath::SkPathJoin | SkOSPath::Join
os.path.basename | SkOSPath::SkBasename | SkOSPath::Basename
BUG=None
TEST=make all
R=mtklein@google.com, bsalomon@google.com
Author: tfarina@chromium.org
Review URL: https://codereview.chromium.org/428443002
36 files changed, 90 insertions, 92 deletions
diff --git a/bench/DecodeBench.cpp b/bench/DecodeBench.cpp index a4717f8eb7..b03f8980cd 100644 --- a/bench/DecodeBench.cpp +++ b/bench/DecodeBench.cpp @@ -20,7 +20,7 @@ class DecodeBench : public Benchmark { SkString fName; public: DecodeBench(SkColorType ct) : fPrefColorType(ct) { - SkString fname = SkOSPath::SkBasename(FLAGS_decodeBenchFilename[0]); + SkString fname = SkOSPath::Basename(FLAGS_decodeBenchFilename[0]); fName.printf("decode_%s_%s", sk_tool_utils::colortype_name(ct), fname.c_str()); } diff --git a/bench/ImageDecodeBench.cpp b/bench/ImageDecodeBench.cpp index 47993cfa7d..3ce2fb0afe 100644 --- a/bench/ImageDecodeBench.cpp +++ b/bench/ImageDecodeBench.cpp @@ -25,7 +25,7 @@ public: , fFilename(filename) , fStream() , fValid(false) { - fName.append(SkOSPath::SkBasename(filename)); + fName.append(SkOSPath::Basename(filename)); } virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { diff --git a/bench/SkipZeroesBench.cpp b/bench/SkipZeroesBench.cpp index 30d9377a5e..fc25f8b074 100644 --- a/bench/SkipZeroesBench.cpp +++ b/bench/SkipZeroesBench.cpp @@ -52,8 +52,7 @@ protected: return; } - SkString fullPath = SkOSPath::SkPathJoin(resourcePath.c_str(), - fFilename.c_str()); + SkString fullPath = SkOSPath::Join(resourcePath.c_str(), fFilename.c_str()); SkFILEStream fileStream(fullPath.c_str()); fValid = fileStream.isValid() && fileStream.getLength() > 0; if (fValid) { diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index f3fdb9f8da..9c5f0e9bd7 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -108,7 +108,7 @@ static void saveFile(const char name[], const char config[], const char dir[], SkString filename; make_filename(name, &filename); filename.appendf("_%s.png", config); - SkString path = SkOSPath::SkPathJoin(dir, filename.c_str()); + SkString path = SkOSPath::Join(dir, filename.c_str()); ::remove(path.c_str()); SkFILEWStream stream(path.c_str()); @@ -128,8 +128,7 @@ static void find_skps(SkTArray<SkString>* skps) { SkString filename; while (it.next(&filename)) { if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, filename.c_str())) { - skps->push_back( - SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str())); + skps->push_back(SkOSPath::Join(FLAGS_skps[0], filename.c_str())); } } } @@ -148,7 +147,7 @@ static void kick_off_skps(const SkTArray<SkString>& skps, exit(1); } - SkString filename = SkOSPath::SkBasename(skps[i].c_str()); + SkString filename = SkOSPath::Basename(skps[i].c_str()); tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic, filename))); tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic, filename, RASTERIZE_PDF_PROC))); diff --git a/dm/DMWriteTask.cpp b/dm/DMWriteTask.cpp index b90e44a2aa..5435087535 100644 --- a/dm/DMWriteTask.cpp +++ b/dm/DMWriteTask.cpp @@ -136,11 +136,11 @@ void WriteTask::draw() { #endif this->makeDirOrFail(dir); for (int i = 0; i < fSuffixes.count(); i++) { - dir = SkOSPath::SkPathJoin(dir.c_str(), fSuffixes[i].c_str()); + dir = SkOSPath::Join(dir.c_str(), fSuffixes[i].c_str()); this->makeDirOrFail(dir); } - SkString path = SkOSPath::SkPathJoin(dir.c_str(), fGmName.c_str()); + SkString path = SkOSPath::Join(dir.c_str(), fGmName.c_str()); path.append(fExtension); const bool ok = fData.get() ? save_data_to_file(fData, path.c_str()) @@ -173,13 +173,13 @@ static SkString path_to_expected_image(const char* root, const Task& task) { SkASSERT(1 == suffixes.count()); // We'll look in root/suffix for images. - const SkString dir = SkOSPath::SkPathJoin(root, suffixes[0].c_str()); + const SkString dir = SkOSPath::Join(root, suffixes[0].c_str()); // Remove the suffix and tack on a .png. filename.remove(filename.size() - suffixLength, suffixLength); filename.append(".png"); - return SkOSPath::SkPathJoin(dir.c_str(), filename.c_str()); + return SkOSPath::Join(dir.c_str(), filename.c_str()); } bool WriteTask::Expectations::check(const Task& task, SkBitmap bitmap) const { diff --git a/experimental/PdfViewer/chop_transparency_main.cpp b/experimental/PdfViewer/chop_transparency_main.cpp index 3f4b1fdee2..c79515d2c9 100644 --- a/experimental/PdfViewer/chop_transparency_main.cpp +++ b/experimental/PdfViewer/chop_transparency_main.cpp @@ -157,7 +157,7 @@ int tool_main(int argc, char** argv) { if (!is_image_file(filename.c_str())) { continue; } - SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str()); + SkString fullname = SkOSPath::Join(dir, filename.c_str()); decodeFileAndWrite(fullname.c_str()); } } else if (sk_exists(readPath) && is_image_file(readPath)) { diff --git a/experimental/PdfViewer/pdf_viewer_main.cpp b/experimental/PdfViewer/pdf_viewer_main.cpp index c1b0284d8a..fab3dc01df 100644 --- a/experimental/PdfViewer/pdf_viewer_main.cpp +++ b/experimental/PdfViewer/pdf_viewer_main.cpp @@ -103,7 +103,7 @@ static bool add_page_and_replace_filename_extension(SkString* path, int page, static bool make_output_filepath(SkString* path, const SkString& dir, const SkString& name, int page) { - *path = SkOSPath::SkPathJoin(dir.c_str(), name.c_str()); + *path = SkOSPath::Join(dir.c_str(), name.c_str()); return add_page_and_replace_filename_extension(path, page, PDF_FILE_EXTENSION, PNG_FILE_EXTENSION); @@ -221,7 +221,7 @@ static bool render_page(const SkString& outputDir, static bool process_pdf(const SkString& inputPath, const SkString& outputDir) { SkDebugf("Loading PDF: %s\n", inputPath.c_str()); - SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str()); + SkString inputFilename = SkOSPath::Basename(inputPath.c_str()); SkAutoTDelete<SkPdfRenderer> renderer(SkPdfRenderer::CreateFromFile(inputPath.c_str())); if (NULL == renderer.get()) { @@ -299,7 +299,7 @@ static int process_input(const char* input, const SkString& outputDir) { SkOSFile::Iter iter(input, PDF_FILE_EXTENSION); SkString inputFilename; while (iter.next(&inputFilename)) { - SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str()); + SkString inputPath = SkOSPath::Join(input, inputFilename.c_str()); if (!process_pdf(inputPath, outputDir)) { ++failures; } diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp index 70890707cf..db6abdf404 100644 --- a/gm/gm_expectations.cpp +++ b/gm/gm_expectations.cpp @@ -194,7 +194,7 @@ namespace skiagm { // IndividualImageExpectationsSource class... Expectations IndividualImageExpectationsSource::get(const char *testName) const { - SkString path = SkOSPath::SkPathJoin(fRootDir.c_str(), testName); + SkString path = SkOSPath::Join(fRootDir.c_str(), testName); SkBitmap referenceBitmap; bool decodedReferenceBitmap = SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap, kN32_SkColorType, diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index d4ec45eb9b..9b51eb0ad6 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -237,7 +237,7 @@ public: filename.append(renderModeDescriptor); filename.appendUnichar('.'); filename.append(suffix); - return SkOSPath::SkPathJoin(path, filename.c_str()); + return SkOSPath::Join(path, filename.c_str()); } /** @@ -257,7 +257,7 @@ public: filename.append(bitmapDigest.getDigestValue()); filename.appendUnichar('.'); filename.append(kPNG_FileExtension); - return SkOSPath::SkPathJoin(path, filename.c_str()); + return SkOSPath::Join(path, filename.c_str()); } else { return make_filename(path, shortName, configName, renderModeDescriptor, kPNG_FileExtension); diff --git a/include/core/SkOSFile.h b/include/core/SkOSFile.h index 1ca11ee932..39eeb4b0b0 100644 --- a/include/core/SkOSFile.h +++ b/include/core/SkOSFile.h @@ -133,7 +133,7 @@ public: * * Uses SkPATH_SEPARATOR, to work on all platforms. */ - static SkString SkPathJoin(const char *rootPath, const char *relativePath); + static SkString Join(const char* rootPath, const char* relativePath); /** * Return the name of the file, ignoring the directory structure. @@ -143,6 +143,7 @@ public: * @return SkString The basename of the file - anything beyond the * final slash, or the full name if there is no slash. */ - static SkString SkBasename(const char* fullPath); + static SkString Basename(const char* fullPath); }; + #endif diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 27365e0b87..a3e9b248ff 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -755,7 +755,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev SkString filename; while (iter.next(&filename)) { *fSamples.append() = new PictFileFactory( - SkOSPath::SkPathJoin(FLAGS_pictureDir[0], filename.c_str())); + SkOSPath::Join(FLAGS_pictureDir[0], filename.c_str())); } } if (!FLAGS_picture.isEmpty()) { @@ -769,7 +769,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev SkString filename; while (iter.next(&filename)) { *fSamples.append() = new PdfFileViewerFactory( - SkOSPath::SkPathJoin(FLAGS_pictureDir[0], filename.c_str())); + SkOSPath::Join(FLAGS_pictureDir[0], filename.c_str())); } } #endif diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp index ab99ecb8ce..bfe69e0b50 100644 --- a/samplecode/SampleUnpremul.cpp +++ b/samplecode/SampleUnpremul.cpp @@ -106,7 +106,7 @@ protected: } // Name, size of the file, and whether or not it is premultiplied. - SkString header(SkOSPath::SkBasename(fCurrFile.c_str())); + SkString header(SkOSPath::Basename(fCurrFile.c_str())); header.appendf(" [%dx%d] %s", fBitmap.width(), fBitmap.height(), (fPremul ? "premultiplied" : "unpremultiplied")); canvas->drawText(header.c_str(), header.size(), 0, height, paint); @@ -167,7 +167,7 @@ private: return; } } - fCurrFile = SkOSPath::SkPathJoin(fResPath.c_str(), basename.c_str()); + fCurrFile = SkOSPath::Join(fResPath.c_str(), basename.c_str()); this->decodeCurrFile(); } diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp index 498d69ffe0..891e4617f3 100644 --- a/src/ports/SkFontHost_linux.cpp +++ b/src/ports/SkFontHost_linux.cpp @@ -323,7 +323,7 @@ private: while (iter.next(&name, false)) { SkString filename( - SkOSPath::SkPathJoin(directory.c_str(), name.c_str())); + SkOSPath::Join(directory.c_str(), name.c_str())); bool isFixedPitch; SkString realname; @@ -354,8 +354,7 @@ private: if (name.startsWith(".")) { continue; } - SkString dirname( - SkOSPath::SkPathJoin(directory.c_str(), name.c_str())); + SkString dirname(SkOSPath::Join(directory.c_str(), name.c_str())); load_directory_fonts(dirname); } } diff --git a/src/utils/SkOSFile.cpp b/src/utils/SkOSFile.cpp index 20ee3a4aad..8baf08ffdd 100644 --- a/src/utils/SkOSFile.cpp +++ b/src/utils/SkOSFile.cpp @@ -6,7 +6,7 @@ */ #include "SkOSFile.h" -SkString SkOSPath::SkPathJoin(const char *rootPath, const char *relativePath) { +SkString SkOSPath::Join(const char *rootPath, const char *relativePath) { SkString result(rootPath); if (!result.endsWith(SkPATH_SEPARATOR)) { result.appendUnichar(SkPATH_SEPARATOR); @@ -15,7 +15,7 @@ SkString SkOSPath::SkPathJoin(const char *rootPath, const char *relativePath) { return result; } -SkString SkOSPath::SkBasename(const char* fullPath) { +SkString SkOSPath::Basename(const char* fullPath) { if (!fullPath) { return SkString(); } diff --git a/tests/DataRefTest.cpp b/tests/DataRefTest.cpp index adb05f9af5..6a58c16507 100644 --- a/tests/DataRefTest.cpp +++ b/tests/DataRefTest.cpp @@ -179,7 +179,7 @@ static void test_files(skiatest::Reporter* reporter) { return; } - SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "data_test"); + SkString path = SkOSPath::Join(tmpDir.c_str(), "data_test"); const char s[] = "abcdefghijklmnopqrstuvwxyz"; { diff --git a/tests/DocumentTest.cpp b/tests/DocumentTest.cpp index 73510f8432..97aefcb4e1 100644 --- a/tests/DocumentTest.cpp +++ b/tests/DocumentTest.cpp @@ -37,7 +37,7 @@ static void test_abortWithFile(skiatest::Reporter* reporter) { // allways, then all these tests will be disabled. } - SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "aborted.pdf"); + SkString path = SkOSPath::Join(tmpDir.c_str(), "aborted.pdf"); // Make sure doc's destructor is called to flush. { @@ -65,7 +65,7 @@ static void test_file(skiatest::Reporter* reporter) { // allways, then all these tests will be disabled. } - SkString path = SkOSPath::SkPathJoin(tmpDir.c_str(), "file.pdf"); + SkString path = SkOSPath::Join(tmpDir.c_str(), "file.pdf"); SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(path.c_str())); diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp index 23625b3874..4fc99c40db 100644 --- a/tests/FontHostTest.cpp +++ b/tests/FontHostTest.cpp @@ -155,7 +155,7 @@ static void test_fontstream(skiatest::Reporter* reporter) { SkDebugf("Could not run fontstream test because resourcePath not specified."); return; } - SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "test.ttc"); + SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); SkFILEStream stream(filename.c_str()); if (stream.isValid()) { diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp index 829851edab..89f59c5cdb 100644 --- a/tests/ImageDecodingTest.cpp +++ b/tests/ImageDecodingTest.cpp @@ -158,7 +158,7 @@ static void test_unpremul(skiatest::Reporter* reporter) { SkString basename; if (iter.next(&basename)) { do { - SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basename.c_str()); + SkString filename = SkOSPath::Join(resourcePath.c_str(), basename.c_str()); // SkDebugf("about to decode \"%s\"\n", filename.c_str()); compare_unpremul(reporter, filename); } while (iter.next(&basename)); @@ -241,7 +241,7 @@ DEF_TEST(ImageDecoding_alphaType, reporter) { SkString basename; if (iter.next(&basename)) { do { - SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), basename.c_str()); + SkString filename = SkOSPath::Join(resourcePath.c_str(), basename.c_str()); for (int truth = 0; truth <= 1; ++truth) { test_alphaType(reporter, filename, SkToBool(truth)); } @@ -264,7 +264,7 @@ DEF_TEST(ImageDecoding_unpremul, reporter) { for (size_t i = 0; i < SK_ARRAY_COUNT(suffixes); ++i) { SkString basename = SkStringPrintf("%s%s", root, suffixes[i]); - SkString fullName = SkOSPath::SkPathJoin(resourcePath.c_str(), basename.c_str()); + SkString fullName = SkOSPath::Join(resourcePath.c_str(), basename.c_str()); SkBitmap bm; SkFILEStream stream(fullName.c_str()); @@ -692,7 +692,7 @@ DEF_TEST(ImageDecoderOptions, reporter) { const bool useDataList[] = {true, false}; for (size_t fidx = 0; fidx < SK_ARRAY_COUNT(files); ++fidx) { - SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), files[fidx]); + SkString path = SkOSPath::Join(resourceDir.c_str(), files[fidx]); if (!sk_exists(path.c_str())) { continue; } @@ -726,7 +726,7 @@ DEF_TEST(ImageDecoderOptions, reporter) { DEF_TEST(DiscardablePixelRef_SecondLockColorTableCheck, r) { SkString resourceDir = GetResourcePath(); - SkString path = SkOSPath::SkPathJoin(resourceDir.c_str(), "randPixels.gif"); + SkString path = SkOSPath::Join(resourceDir.c_str(), "randPixels.gif"); if (!sk_exists(path.c_str())) { return; } diff --git a/tests/OSPathTest.cpp b/tests/OSPathTest.cpp index d36b7cb0cf..1452c3852e 100644 --- a/tests/OSPathTest.cpp +++ b/tests/OSPathTest.cpp @@ -10,9 +10,9 @@ #include "Test.h" /** - * Test SkPathJoin and SkBasename. - * Will use SkPathJoin to append filename to dir, test that it works correctly, - * and tests using SkBasename on the result. + * Test SkOSPath::Join and SkOSPath::Basename. + * Will use SkOSPath::Join to append filename to dir, test that it works correctly, + * and tests using SkOSPath::Basename on the result. * @param reporter Reporter for test conditions. * @param dir String representing the path to a folder. May or may not * end with SkPATH_SEPARATOR. @@ -24,10 +24,10 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir, // If filename contains SkPATH_SEPARATOR, the tests will fail. SkASSERT(!filename.contains(SkPATH_SEPARATOR)); - // Tests for SkOSPath::SkPathJoin and SkOSPath::SkBasename + // Tests for SkOSPath::Join and SkOSPath::Basename // fullName should be "dir<SkPATH_SEPARATOR>file" - SkString fullName = SkOSPath::SkPathJoin(dir.c_str(), filename.c_str()); + SkString fullName = SkOSPath::Join(dir.c_str(), filename.c_str()); // fullName should be the combined size of dir and file, plus one if // dir did not include the final path separator. @@ -37,7 +37,7 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir, } REPORTER_ASSERT(reporter, fullName.size() == expectedSize); - SkString basename = SkOSPath::SkBasename(fullName.c_str()); + SkString basename = SkOSPath::Basename(fullName.c_str()); // basename should be the same as filename REPORTER_ASSERT(reporter, basename.equals(filename)); @@ -46,7 +46,7 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir, REPORTER_ASSERT(reporter, !basename.contains(SkPATH_SEPARATOR)); // Now take the basename of filename, which should be the same as filename. - basename = SkOSPath::SkBasename(filename.c_str()); + basename = SkOSPath::Basename(filename.c_str()); REPORTER_ASSERT(reporter, basename.equals(filename)); } @@ -71,15 +71,15 @@ DEF_TEST(OSPath, reporter) { // Basename of a directory with a path separator at the end is empty. dir.appendUnichar(SkPATH_SEPARATOR); - SkString baseOfDir = SkOSPath::SkBasename(dir.c_str()); + SkString baseOfDir = SkOSPath::Basename(dir.c_str()); REPORTER_ASSERT(reporter, baseOfDir.size() == 0); // Basename of NULL is an empty string. - SkString empty = SkOSPath::SkBasename(NULL); + SkString empty = SkOSPath::Basename(NULL); REPORTER_ASSERT(reporter, empty.size() == 0); // Test that NULL can be used for the directory and filename. - SkString emptyPath = SkOSPath::SkPathJoin(NULL, NULL); + SkString emptyPath = SkOSPath::Join(NULL, NULL); REPORTER_ASSERT(reporter, emptyPath.size() == 1); REPORTER_ASSERT(reporter, emptyPath.contains(SkPATH_SEPARATOR)); } diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index 3a443f3b9c..2dc0c62cb5 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -299,7 +299,7 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { SkDebugf("Could not run fontstream test because resourcePath not specified."); return; } - SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "test.ttc"); + SkString filename = SkOSPath::Join(resourcePath.c_str(), "test.ttc"); SkTypeface* typeface = SkTypeface::CreateFromFile(filename.c_str()); if (!typeface) { SkDebugf("Could not run fontstream test because test.ttc not found."); diff --git a/tests/StreamTest.cpp b/tests/StreamTest.cpp index 7cf3126d61..ce391a398a 100644 --- a/tests/StreamTest.cpp +++ b/tests/StreamTest.cpp @@ -37,7 +37,7 @@ static void test_loop_stream(skiatest::Reporter* reporter, SkStream* stream, } static void test_filestreams(skiatest::Reporter* reporter, const char* tmpDir) { - SkString path = SkOSPath::SkPathJoin(tmpDir, "wstream_test"); + SkString path = SkOSPath::Join(tmpDir, "wstream_test"); const char s[] = "abcdefghijklmnopqrstuvwxyz"; diff --git a/tools/CopyTilesRenderer.cpp b/tools/CopyTilesRenderer.cpp index 7e6f8a8226..509dd0e595 100644 --- a/tools/CopyTilesRenderer.cpp +++ b/tools/CopyTilesRenderer.cpp @@ -72,8 +72,8 @@ namespace sk_tools { // a bitmap directly. // TODO: Share more common code with write() to do this, to properly // write out the JSON summary, etc. - SkString pathWithNumber = SkOSPath::SkPathJoin(fWritePath.c_str(), - fInputFilename.c_str()); + SkString pathWithNumber = SkOSPath::Join(fWritePath.c_str(), + fInputFilename.c_str()); pathWithNumber.remove(pathWithNumber.size() - 4, 4); pathWithNumber.appendf("%i.png", i++); SkBitmap copy; diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index 3793b85461..dd4cea481d 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -363,7 +363,7 @@ bool RecordPictureRenderer::render(SkBitmap** out) { SkAutoTUnref<SkPicture> picture(recorder.endRecording()); if (!fWritePath.isEmpty()) { // Record the new picture as a new SKP with PNG encoded bitmaps. - SkString skpPath = SkOSPath::SkPathJoin(fWritePath.c_str(), fInputFilename.c_str()); + SkString skpPath = SkOSPath::Join(fWritePath.c_str(), fInputFilename.c_str()); SkFILEWStream stream(skpPath.c_str()); picture->serialize(&stream, &encode_bitmap_to_data); return true; diff --git a/tools/Resources.cpp b/tools/Resources.cpp index 0efd66b246..606c5c4968 100644 --- a/tools/Resources.cpp +++ b/tools/Resources.cpp @@ -13,7 +13,7 @@ DEFINE_string2(resourcePath, i, "resources", "Directory with test resources: images, fonts, etc."); SkString GetResourcePath(const char* resource) { - return SkOSPath::SkPathJoin(FLAGS_resourcePath[0], resource); + return SkOSPath::Join(FLAGS_resourcePath[0], resource); } void SetResourcePath(const char* resource) { diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index f6cd8e9bd7..b740877cce 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -197,7 +197,7 @@ static bool run_single_benchmark(const SkString& inputPath, return false; } - SkString filename = SkOSPath::SkBasename(inputPath.c_str()); + SkString filename = SkOSPath::Basename(inputPath.c_str()); gWriter.bench(filename.c_str(), picture->width(), picture->height()); @@ -376,7 +376,7 @@ static int process_input(const char* input, int failures = 0; if (iter.next(&inputFilename)) { do { - SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str()); + SkString inputPath = SkOSPath::Join(input, inputFilename.c_str()); if (!run_single_benchmark(inputPath, benchmark)) { ++failures; } diff --git a/tools/bench_playback.cpp b/tools/bench_playback.cpp index 5343191974..a4f3a6a394 100644 --- a/tools/bench_playback.cpp +++ b/tools/bench_playback.cpp @@ -106,7 +106,7 @@ int tool_main(int argc, char** argv) { continue; } - const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str()); + const SkString path = SkOSPath::Join(FLAGS_skps[0], filename.c_str()); SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); if (!stream) { diff --git a/tools/bench_record.cpp b/tools/bench_record.cpp index 545731900b..4f928ee6dc 100644 --- a/tools/bench_record.cpp +++ b/tools/bench_record.cpp @@ -149,7 +149,7 @@ int tool_main(int argc, char** argv) { continue; } - const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str()); + const SkString path = SkOSPath::Join(FLAGS_skps[0], filename.c_str()); SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); if (!stream) { diff --git a/tools/filtermain.cpp b/tools/filtermain.cpp index 0830c80e30..9df6c078e7 100644 --- a/tools/filtermain.cpp +++ b/tools/filtermain.cpp @@ -816,9 +816,9 @@ int tool_main(int argc, char** argv) { if (iter.next(&inputFilename)) { do { - inFile = SkOSPath::SkPathJoin(inDir.c_str(), inputFilename.c_str()); + inFile = SkOSPath::Join(inDir.c_str(), inputFilename.c_str()); if (!outDir.isEmpty()) { - outFile = SkOSPath::SkPathJoin(outDir.c_str(), inputFilename.c_str()); + outFile = SkOSPath::Join(outDir.c_str(), inputFilename.c_str()); } SkDebugf("Executing %s\n", inputFilename.c_str()); filter_picture(inFile, outFile); diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp index 2985bf64c3..e19b7a314a 100644 --- a/tools/lua/lua_pictures.cpp +++ b/tools/lua/lua_pictures.cpp @@ -132,7 +132,7 @@ int tool_main(int argc, char** argv) { SkString filename; SkOSFile::Iter iter(FLAGS_skpPath[i], "skp"); while(iter.next(&filename)) { - paths.push_back() = SkOSPath::SkPathJoin(directory.c_str(), filename.c_str()); + paths.push_back() = SkOSPath::Join(directory.c_str(), filename.c_str()); } } else { // Add this as an .skp itself. diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp index 597fd4878f..6a35dd1d70 100644 --- a/tools/picture_utils.cpp +++ b/tools/picture_utils.cpp @@ -55,12 +55,12 @@ namespace sk_tools { const char *subdirOrNull, const SkString& baseName) { SkString partialPath; if (subdirOrNull) { - partialPath = SkOSPath::SkPathJoin(dirPath.c_str(), subdirOrNull); + partialPath = SkOSPath::Join(dirPath.c_str(), subdirOrNull); sk_mkdir(partialPath.c_str()); } else { partialPath.set(dirPath); } - SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c_str()); + SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str()); if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPNG_Type, 100)) { return true; } else { diff --git a/tools/render_pdfs_main.cpp b/tools/render_pdfs_main.cpp index 5e337009c6..6e1d609cde 100644 --- a/tools/render_pdfs_main.cpp +++ b/tools/render_pdfs_main.cpp @@ -111,7 +111,7 @@ static SkData* encode_to_dct_data(size_t*, const SkBitmap& bitmap) { */ static bool make_output_filepath(SkString* path, const SkString& dir, const SkString& name) { - *path = SkOSPath::SkPathJoin(dir.c_str(), name.c_str()); + *path = SkOSPath::Join(dir.c_str(), name.c_str()); return replace_filename_extension(path, SKP_FILE_EXTENSION, PDF_FILE_EXTENSION); @@ -149,7 +149,7 @@ static SkWStream* open_stream(const SkString& outputDir, */ static bool render_pdf(const SkString& inputPath, const SkString& outputDir, sk_tools::PdfRenderer& renderer) { - SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str()); + SkString inputFilename = SkOSPath::Basename(inputPath.c_str()); SkFILEStream inputStream; inputStream.setPath(inputPath.c_str()); @@ -197,7 +197,7 @@ static int process_input(const SkString& input, const SkString& outputDir, SkOSFile::Iter iter(input.c_str(), SKP_FILE_EXTENSION); SkString inputFilename; while (iter.next(&inputFilename)) { - SkString inputPath = SkOSPath::SkPathJoin(input.c_str(), inputFilename.c_str()); + SkString inputPath = SkOSPath::Join(input.c_str(), inputFilename.c_str()); if (!render_pdf(inputPath, outputDir, renderer)) { ++failures; } diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index c2c7875b28..e2f772908f 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -123,7 +123,7 @@ static bool write_image_to_file(const void* buffer, size_t size, SkBitmap* bitma SkString name = SkStringPrintf("%s_%d%s", gInputFileName.c_str(), gImageNo++, get_suffix_from_format(format)); SkString dir(FLAGS_writePath[0]); - outPath = SkOSPath::SkPathJoin(dir.c_str(), name.c_str()); + outPath = SkOSPath::Join(dir.c_str(), name.c_str()); SkFILEWStream fileStream(outPath.c_str()); if (!(fileStream.isValid() && fileStream.write(buffer, size))) { SkDebugf("Failed to write encoded data to \"%s\"\n", outPath.c_str()); @@ -142,7 +142,7 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w const SkString* mismatchPath, sk_tools::PictureRenderer& renderer, SkBitmap** out) { - SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str()); + SkString inputFilename = SkOSPath::Basename(inputPath.c_str()); SkString writePathString; if (NULL != writePath && writePath->size() > 0 && !FLAGS_writeEncodedImages) { writePathString.set(*writePath); @@ -345,7 +345,7 @@ static bool render_picture(const SkString& inputPath, const SkString* writePath, if (FLAGS_writeWholeImage) { sk_tools::force_all_opaque(*bitmap); - SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str()); + SkString inputFilename = SkOSPath::Basename(inputPath.c_str()); SkString outputFilename(inputFilename); sk_tools::replace_char(&outputFilename, '.', '_'); outputFilename.append(".png"); @@ -379,7 +379,7 @@ static int process_input(const char* input, const SkString* writePath, SkDebugf("process_input, %s\n", input); if (iter.next(&inputFilename)) { do { - SkString inputPath = SkOSPath::SkPathJoin(input, inputFilename.c_str()); + SkString inputPath = SkOSPath::Join(input, inputFilename.c_str()); if (!render_picture(inputPath, writePath, mismatchPath, renderer, jsonSummaryPtr)) { ++failures; } diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp index cd58eacd59..60bdd05485 100644 --- a/tools/skimage_main.cpp +++ b/tools/skimage_main.cpp @@ -80,8 +80,8 @@ static SkImageDecoder::Format guess_format_from_suffix(const char suffix[]) { static void make_outname(SkString* dst, const char outDir[], const char src[], const char suffix[]) { - SkString basename = SkOSPath::SkBasename(src); - dst->set(SkOSPath::SkPathJoin(outDir, basename.c_str())); + SkString basename = SkOSPath::Basename(src); + dst->set(SkOSPath::Join(outDir, basename.c_str())); dst->append(suffix); } @@ -138,14 +138,14 @@ static bool write_bitmap(const char outDir[], const char src[], if (FLAGS_writeChecksumBasedFilenames) { // First create the directory for the hashtype. const SkString hashType = bitmapAndDigest.fDigest.getHashType(); - const SkString hashDir = SkOSPath::SkPathJoin(outDir, hashType.c_str()); + const SkString hashDir = SkOSPath::Join(outDir, hashType.c_str()); if (!sk_mkdir(hashDir.c_str())) { return false; } // Now create the name of the folder specific to this image. - SkString basename = SkOSPath::SkBasename(src); - const SkString imageDir = SkOSPath::SkPathJoin(hashDir.c_str(), basename.c_str()); + SkString basename = SkOSPath::Basename(src); + const SkString imageDir = SkOSPath::Join(hashDir.c_str(), basename.c_str()); if (!sk_mkdir(imageDir.c_str())) { return false; } @@ -154,7 +154,7 @@ static bool write_bitmap(const char outDir[], const char src[], SkString checksumBasedName = bitmapAndDigest.fDigest.getDigestValue(); checksumBasedName.append(".png"); - filename = SkOSPath::SkPathJoin(imageDir.c_str(), checksumBasedName.c_str()); + filename = SkOSPath::Join(imageDir.c_str(), checksumBasedName.c_str()); } else { make_outname(&filename, outDir, src, ".png"); } @@ -358,7 +358,7 @@ static bool write_subset(const char* writePath, const SkString& subsetName, subsetPath.set(writePath); } else { // Create a subdirectory to hold the results of decodeSubset. - subsetPath = SkOSPath::SkPathJoin(writePath, "subsets"); + subsetPath = SkOSPath::Join(writePath, "subsets"); if (!sk_mkdir(subsetPath.c_str())) { gFailedSubsetDecodes.push_back().printf("Successfully decoded subset %s, but " "failed to create a directory to write to.", @@ -385,7 +385,7 @@ static bool write_subset(const char* writePath, const SkString& subsetName, return false; } - SkString dirExtracted = SkOSPath::SkPathJoin(writePath, "extracted"); + SkString dirExtracted = SkOSPath::Join(writePath, "extracted"); if (!sk_mkdir(dirExtracted.c_str())) { gFailedSubsetDecodes.push_back().printf("Successfully decoded subset%s, but failed " "to create a directory for extractSubset " @@ -502,7 +502,7 @@ static void decodeFileAndWrite(const char srcPath[], const SkString* writePath) stream.rewind(); // Create a string representing just the filename itself, for use in json expectations. - SkString basename = SkOSPath::SkBasename(srcPath); + SkString basename = SkOSPath::Basename(srcPath); // Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENAME_PATTERN replace_char(&basename, '_', '-'); // Replace '.' with '-', so the output filename can still retain the original file extension, @@ -796,7 +796,7 @@ int tool_main(int argc, char** argv) { if (!is_image_file(filename.c_str())) { continue; } - SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str()); + SkString fullname = SkOSPath::Join(dir, filename.c_str()); decodeFileAndWrite(fullname.c_str(), outDirPtr); } } else if (sk_exists(readPath) && is_image_file(readPath)) { diff --git a/tools/skpdiff/SkDiffContext.cpp b/tools/skpdiff/SkDiffContext.cpp index 26898c92f3..ea44c90da1 100644 --- a/tools/skpdiff/SkDiffContext.cpp +++ b/tools/skpdiff/SkDiffContext.cpp @@ -98,8 +98,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) { fRecordMutex.release(); // compute the common name - SkString baseName = SkOSPath::SkBasename(baselinePath); - SkString testName = SkOSPath::SkBasename(testPath); + SkString baseName = SkOSPath::Basename(baselinePath); + SkString testName = SkOSPath::Basename(testPath); newRecord->fCommonName = get_common_prefix(baseName, testName); newRecord->fBaselinePath = baselinePath; @@ -134,8 +134,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) { && !diffData.fResult.poiAlphaMask.empty() && !newRecord->fCommonName.isEmpty()) { - newRecord->fAlphaMaskPath = SkOSPath::SkPathJoin(fAlphaMaskDir.c_str(), - newRecord->fCommonName.c_str()); + newRecord->fAlphaMaskPath = SkOSPath::Join(fAlphaMaskDir.c_str(), + newRecord->fCommonName.c_str()); // compute the image diff and output it SkBitmap copy; @@ -163,8 +163,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) { newRecord->fMaxGreenDiff = diffData.fResult.maxGreenDiff; newRecord->fMaxBlueDiff = diffData.fResult.maxBlueDiff; - newRecord->fRgbDiffPath = SkOSPath::SkPathJoin(fRgbDiffDir.c_str(), - newRecord->fCommonName.c_str()); + newRecord->fRgbDiffPath = SkOSPath::Join(fRgbDiffDir.c_str(), + newRecord->fCommonName.c_str()); SkImageEncoder::EncodeFile(newRecord->fRgbDiffPath.c_str(), diffData.fResult.rgbDiffBitmap, SkImageEncoder::kPNG_Type, 100); @@ -176,8 +176,8 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) { && SkImageDiffer::RESULT_CORRECT != diffData.fResult.result && !diffData.fResult.whiteDiffBitmap.empty() && !newRecord->fCommonName.isEmpty()) { - newRecord->fWhiteDiffPath = SkOSPath::SkPathJoin(fWhiteDiffDir.c_str(), - newRecord->fCommonName.c_str()); + newRecord->fWhiteDiffPath = SkOSPath::Join(fWhiteDiffDir.c_str(), + newRecord->fCommonName.c_str()); SkImageEncoder::EncodeFile(newRecord->fWhiteDiffPath.c_str(), diffData.fResult.whiteDiffBitmap, SkImageEncoder::kPNG_Type, 100); @@ -223,8 +223,8 @@ void SkDiffContext::diffDirectories(const char baselinePath[], const char testPa const char* baseFilename = baselineEntries[x].c_str(); // Find the real location of each file to compare - SkString baselineFile = SkOSPath::SkPathJoin(baselinePath, baseFilename); - SkString testFile = SkOSPath::SkPathJoin(testPath, baseFilename); + SkString baselineFile = SkOSPath::Join(baselinePath, baseFilename); + SkString testFile = SkOSPath::Join(testPath, baseFilename); // Check that the test file exists and is a file if (sk_exists(testFile.c_str()) && !sk_isdir(testFile.c_str())) { diff --git a/tools/skpdiff/skpdiff_util.cpp b/tools/skpdiff/skpdiff_util.cpp index 983bee20b3..4a92f5e3f7 100644 --- a/tools/skpdiff/skpdiff_util.cpp +++ b/tools/skpdiff/skpdiff_util.cpp @@ -117,7 +117,7 @@ bool get_directory(const char path[], SkTArray<SkString>* entries) { while ((entry = readdir(dir))) { // dirent only gives relative paths, we need to join them to the base path to check if they // are directories. - SkString joinedPath = SkOSPath::SkPathJoin(path, entry->d_name); + SkString joinedPath = SkOSPath::Join(path, entry->d_name); // We only care about files if (!sk_isdir(joinedPath.c_str())) { |