aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-01-05 10:55:28 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-05 17:53:15 +0000
commit7a600416e131b33610b1c96a367b3cb2569f458e (patch)
tree5f283eb22f84d9057123e36169e643bd3af3e906 /src/utils
parent18eafd922d911606dfe991efad8ec5eaafbc2704 (diff)
allow both slash types
Windows allows forwards and backwards slashes for path directory delimiters. R=halcanary@google.com Change-Id: Ie6f1257c98ac8e2468d9297b5dc391fd17f4ae82 Reviewed-on: https://skia-review.googlesource.com/90821 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/SkOSPath.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/utils/SkOSPath.cpp b/src/utils/SkOSPath.cpp
index d9a5ac53f3..7898fb1e46 100644
--- a/src/utils/SkOSPath.cpp
+++ b/src/utils/SkOSPath.cpp
@@ -9,7 +9,8 @@
SkString SkOSPath::Join(const char *rootPath, const char *relativePath) {
SkString result(rootPath);
- if (!result.endsWith(SEPARATOR) && !result.isEmpty()) {
+ if (!result.endsWith(SEPARATOR) && ('\\' != SEPARATOR || !result.endsWith('/')) &&
+ !result.isEmpty()) {
result.appendUnichar(SEPARATOR);
}
result.append(relativePath);
@@ -21,6 +22,12 @@ SkString SkOSPath::Basename(const char* fullPath) {
return SkString();
}
const char* filename = strrchr(fullPath, SEPARATOR);
+ if ('\\' == SEPARATOR) {
+ const char* alternate = strrchr(fullPath, '/');
+ if (filename < alternate) {
+ filename = alternate;
+ }
+ }
if (nullptr == filename) {
filename = fullPath;
} else {
@@ -34,11 +41,17 @@ SkString SkOSPath::Dirname(const char* fullPath) {
return SkString();
}
const char* end = strrchr(fullPath, SEPARATOR);
+ if ('\\' == SEPARATOR) {
+ const char* alternate = strrchr(fullPath, '/');
+ if (end < alternate) {
+ end = alternate;
+ }
+ }
if (nullptr == end) {
return SkString();
}
if (end == fullPath) {
- SkASSERT(fullPath[0] == SEPARATOR);
+ SkASSERT(fullPath[0] == SEPARATOR || ('\\' == SEPARATOR && fullPath[0] == '/'));
++end;
}
return SkString(fullPath, end - fullPath);