aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkOSFile.cpp
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-28 16:45:07 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-28 16:45:07 +0000
commitccd7afb6fb2df9774e57fb4d7f62f9504cabf03e (patch)
tree54818885b59f98ac958e6c35d67109b098f26a19 /src/utils/SkOSFile.cpp
parent7b06ba45b34855a5bb16f9c729813173d7dfe47d (diff)
Reland 'Add path utils, plus a test for it.'
Build SkPathJoin and SkBasename on windows also. Previous CL did not build on Windows because the two functions were accidentally placed inside an ifdef that did not include windows. Move the functions to the top of the file, and add a comment by the endif for clarity. Previously reviewed at https://codereview.chromium.org/15747004/ Review URL: https://codereview.chromium.org/15740024 git-svn-id: http://skia.googlecode.com/svn/trunk@9295 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/SkOSFile.cpp')
-rw-r--r--src/utils/SkOSFile.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/utils/SkOSFile.cpp b/src/utils/SkOSFile.cpp
index 478a0cc448..0a403750b8 100644
--- a/src/utils/SkOSFile.cpp
+++ b/src/utils/SkOSFile.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2011 Google Inc.
*
@@ -7,6 +6,28 @@
*/
#include "SkOSFile.h"
+SkString SkOSPath::SkPathJoin(const char *rootPath, const char *relativePath) {
+ SkString result(rootPath);
+ if (!result.endsWith(SkPATH_SEPARATOR)) {
+ result.appendUnichar(SkPATH_SEPARATOR);
+ }
+ result.append(relativePath);
+ return result;
+}
+
+SkString SkOSPath::SkBasename(const char* fullPath) {
+ if (!fullPath) {
+ return SkString();
+ }
+ const char* filename = strrchr(fullPath, SkPATH_SEPARATOR);
+ if (NULL == filename) {
+ filename = fullPath;
+ } else {
+ ++filename;
+ }
+ return SkString(filename);
+}
+
#ifdef SK_BUILD_FOR_WIN
static uint16_t* concat_to_16(const char src[], const char suffix[])
@@ -225,5 +246,4 @@ bool SkOSFile::Iter::next(SkString* name, bool getDir)
}
return false;
}
-
-#endif
+#endif // if one of:SK_BUILD_FOR_MAC, SK_BUILD_FOR_UNIX, SK_BUILD_FOR_ANDROID,SK_BUILD_FOR_IOS