Cleanup: Delete sk_tools::get_basename() in favor of SkOSPath::SkBasename().

BUG=None
TEST=make tests && out/Debug/tests
R=epoger@google.com

Author: tfarina@chromium.org

Review URL: https://codereview.chromium.org/321693002
diff --git a/tests/PictureUtilsTest.cpp b/tests/PictureUtilsTest.cpp
index 069e852..9214d07 100644
--- a/tests/PictureUtilsTest.cpp
+++ b/tests/PictureUtilsTest.cpp
@@ -5,48 +5,15 @@
  * found in the LICENSE file.
  */
 
-#include "SkString.h"
-#include "Test.h"
 #include "picture_utils.h"
 
-static void test_filepath_creation(skiatest::Reporter* reporter) {
+#include "SkString.h"
+#include "Test.h"
+
+DEF_TEST(PictureUtils, reporter) {
     SkString result;
     SkString filename("test");
     SkString dir("test/path");
     sk_tools::make_filepath(&result, dir, filename);
     REPORTER_ASSERT(reporter, result.equals("test/path/test"));
 }
-
-static void test_get_basename(skiatest::Reporter* reporter) {
-    SkString result;
-    SkString path("/path/basename");
-    sk_tools::get_basename(&result, path);
-    REPORTER_ASSERT(reporter, result.equals("basename"));
-
-    result.reset();
-    path.set("/path/dir/");
-    sk_tools::get_basename(&result, path);
-    REPORTER_ASSERT(reporter, result.equals("dir"));
-
-    result.reset();
-    path.set("path");
-    sk_tools::get_basename(&result, path);
-    REPORTER_ASSERT(reporter, result.equals("path"));
-
-#if defined(SK_BUILD_FOR_WIN)
-    result.reset();
-    path.set("path\\winbasename");
-    sk_tools::get_basename(&result, path);
-    REPORTER_ASSERT(reporter, result.equals("winbasename"));
-
-    result.reset();
-    path.set("path\\windir\\");
-    sk_tools::get_basename(&result, path);
-    REPORTER_ASSERT(reporter, result.equals("windir"));
-#endif
-}
-
-DEF_TEST(PictureUtils, reporter) {
-    test_filepath_creation(reporter);
-    test_get_basename(reporter);
-}
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index b79dfed..4d4116d 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -191,8 +191,7 @@
         return false;
     }
 
-    SkString filename;
-    sk_tools::get_basename(&filename, inputPath);
+    SkString filename = SkOSPath::SkBasename(inputPath.c_str());
 
     gWriter.bench(filename.c_str(), picture->width(), picture->height());
 
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index 4e6c81e..850e21f 100644
--- a/tools/picture_utils.cpp
+++ b/tools/picture_utils.cpp
@@ -14,14 +14,6 @@
 #include "SkStream.h"
 #include "SkString.h"
 
-static bool is_path_seperator(const char chr) {
-#if defined(SK_BUILD_FOR_WIN)
-    return chr == '\\' || chr == '/';
-#else
-    return chr == '/';
-#endif
-}
-
 namespace sk_tools {
     void force_all_opaque(const SkBitmap& bitmap) {
         SkASSERT(NULL == bitmap.getTexture());
@@ -58,39 +50,6 @@
         path->append(name);
     }
 
-    void get_basename(SkString* basename, const SkString& path) {
-        if (path.size() == 0) {
-            basename->reset();
-            return;
-        }
-
-        size_t end = path.size() - 1;
-
-        // Paths pointing to directories often have a trailing slash,
-        // we remove it so the name is not empty
-        if (is_path_seperator(path[end])) {
-            if (end == 0) {
-                basename->reset();
-                return;
-            }
-
-            end -= 1;
-        }
-
-        size_t i = end;
-        do {
-            --i;
-            if (is_path_seperator(path[i])) {
-                  const char* basenameStart = path.c_str() + i + 1;
-                  size_t basenameLength = end - i;
-                  basename->set(basenameStart, basenameLength);
-                  return;
-            }
-        } while (i > 0);
-
-        basename->set(path.c_str(), end + 1);
-    }
-
     bool is_percentage(const char* const string) {
         SkString skString(string);
         return skString.endsWith("%");
diff --git a/tools/picture_utils.h b/tools/picture_utils.h
index c0e0d2c..2e1af7b 100644
--- a/tools/picture_utils.h
+++ b/tools/picture_utils.h
@@ -38,13 +38,6 @@
     // TODO(epoger): delete in favor of SkOSPath::SkPathJoin()?
     void make_filepath(SkString* path, const SkString&, const SkString& name);
 
-    // Returns the last part of the path (file name or leaf directory name)
-    //
-    // This basically just looks for a foward slash or backslash (windows
-    // only).
-    // TODO(epoger): delete in favor of SkOSPath::SkBasename()?
-    void get_basename(SkString* basename, const SkString& path);
-
     // Returns true if the string ends with %
     bool is_percentage(const char* const string);
 
diff --git a/tools/render_pdfs_main.cpp b/tools/render_pdfs_main.cpp
index 7790e2a..fd078d3 100644
--- a/tools/render_pdfs_main.cpp
+++ b/tools/render_pdfs_main.cpp
@@ -149,8 +149,7 @@
  */
 static bool render_pdf(const SkString& inputPath, const SkString& outputDir,
                        sk_tools::PdfRenderer& renderer) {
-    SkString inputFilename;
-    sk_tools::get_basename(&inputFilename, inputPath);
+    SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
 
     SkFILEStream inputStream;
     inputStream.setPath(inputPath.c_str());
diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp
index e054acf..8a5c771 100644
--- a/tools/render_pictures_main.cpp
+++ b/tools/render_pictures_main.cpp
@@ -143,8 +143,7 @@
                                     const SkString* mismatchPath,
                                     sk_tools::PictureRenderer& renderer,
                                     SkBitmap** out) {
-    SkString inputFilename;
-    sk_tools::get_basename(&inputFilename, inputPath);
+    SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
     SkString writePathString;
     if (NULL != writePath && writePath->size() > 0 && !FLAGS_writeEncodedImages) {
         writePathString.set(*writePath);
@@ -353,8 +352,7 @@
     if (FLAGS_writeWholeImage) {
         sk_tools::force_all_opaque(*bitmap);
 
-        SkString inputFilename;
-        sk_tools::get_basename(&inputFilename, inputPath);
+        SkString inputFilename = SkOSPath::SkBasename(inputPath.c_str());
         SkString outputFilename(inputFilename);
         sk_tools::replace_char(&outputFilename, '.', '_');
         outputFilename.append(".png");