aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar tfarina <tfarina@chromium.org>2014-06-11 08:58:50 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-11 08:58:50 -0700
commit1c99ea8ed80ca492397717b57e2735869be38c69 (patch)
tree2b1c41d3b4054dc614e5c1dda55562c98c52fdb0 /tools
parent1acb8df76dd915f4f48dd0b9618a4ec1478f72a4 (diff)
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
Diffstat (limited to 'tools')
-rw-r--r--tools/bench_pictures_main.cpp3
-rw-r--r--tools/picture_utils.cpp41
-rw-r--r--tools/picture_utils.h7
-rw-r--r--tools/render_pdfs_main.cpp3
-rw-r--r--tools/render_pictures_main.cpp6
5 files changed, 4 insertions, 56 deletions
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index b79dfedff2..4d4116db01 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -191,8 +191,7 @@ static bool run_single_benchmark(const SkString& inputPath,
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 4e6c81e417..850e21f8e7 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 @@ namespace sk_tools {
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 c0e0d2c8dd..2e1af7b78c 100644
--- a/tools/picture_utils.h
+++ b/tools/picture_utils.h
@@ -38,13 +38,6 @@ namespace sk_tools {
// 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 7790e2a4e7..fd078d3901 100644
--- a/tools/render_pdfs_main.cpp
+++ b/tools/render_pdfs_main.cpp
@@ -149,8 +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;
- 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 e054acf67d..8a5c7713a2 100644
--- a/tools/render_pictures_main.cpp
+++ b/tools/render_pictures_main.cpp
@@ -143,8 +143,7 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w
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 @@ static bool render_picture(const SkString& inputPath, const SkString* writePath,
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");