aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkOSPath.cpp
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2016-11-07 18:05:29 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-08 20:20:15 +0000
commitbf111d7bc9ba3857433e30eae27f0272c34ed0fb (patch)
tree878660f011e2513791d588b621bc16fa047484da /src/utils/SkOSPath.cpp
parentfa2c4788ce04f80ff7a5887613d93a4053cd174b (diff)
Move SkOSPath out of include/core.
It is moved to src/utils. It is almost a tool, but has two uses in src/ports. The existing SkOSFile.cpp is left empty for the time being since it is mentioned in Chromium's BUILD.gn for Skia. Change-Id: I3bb7f7c4214359eb6ab906bfe76737d20bf1d6c7 Reviewed-on: https://skia-review.googlesource.com/4536 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/utils/SkOSPath.cpp')
-rw-r--r--src/utils/SkOSPath.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/utils/SkOSPath.cpp b/src/utils/SkOSPath.cpp
new file mode 100644
index 0000000000..d9a5ac53f3
--- /dev/null
+++ b/src/utils/SkOSPath.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkOSPath.h"
+
+SkString SkOSPath::Join(const char *rootPath, const char *relativePath) {
+ SkString result(rootPath);
+ if (!result.endsWith(SEPARATOR) && !result.isEmpty()) {
+ result.appendUnichar(SEPARATOR);
+ }
+ result.append(relativePath);
+ return result;
+}
+
+SkString SkOSPath::Basename(const char* fullPath) {
+ if (!fullPath) {
+ return SkString();
+ }
+ const char* filename = strrchr(fullPath, SEPARATOR);
+ if (nullptr == filename) {
+ filename = fullPath;
+ } else {
+ ++filename;
+ }
+ return SkString(filename);
+}
+
+SkString SkOSPath::Dirname(const char* fullPath) {
+ if (!fullPath) {
+ return SkString();
+ }
+ const char* end = strrchr(fullPath, SEPARATOR);
+ if (nullptr == end) {
+ return SkString();
+ }
+ if (end == fullPath) {
+ SkASSERT(fullPath[0] == SEPARATOR);
+ ++end;
+ }
+ return SkString(fullPath, end - fullPath);
+}