summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/utils/SkOSPath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/skia/skia/src/utils/SkOSPath.cpp')
-rw-r--r--gfx/skia/skia/src/utils/SkOSPath.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/utils/SkOSPath.cpp b/gfx/skia/skia/src/utils/SkOSPath.cpp
new file mode 100644
index 0000000000..f960d1fde4
--- /dev/null
+++ b/gfx/skia/skia/src/utils/SkOSPath.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "src/utils/SkOSPath.h"
+
+#include "include/core/SkTypes.h"
+
+#include <string.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);
+}