aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/utils/SkOSPath.cpp17
-rw-r--r--tests/OSPathTest.cpp17
2 files changed, 4 insertions, 30 deletions
diff --git a/src/utils/SkOSPath.cpp b/src/utils/SkOSPath.cpp
index 7898fb1e46..d9a5ac53f3 100644
--- a/src/utils/SkOSPath.cpp
+++ b/src/utils/SkOSPath.cpp
@@ -9,8 +9,7 @@
SkString SkOSPath::Join(const char *rootPath, const char *relativePath) {
SkString result(rootPath);
- if (!result.endsWith(SEPARATOR) && ('\\' != SEPARATOR || !result.endsWith('/')) &&
- !result.isEmpty()) {
+ if (!result.endsWith(SEPARATOR) && !result.isEmpty()) {
result.appendUnichar(SEPARATOR);
}
result.append(relativePath);
@@ -22,12 +21,6 @@ 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 {
@@ -41,17 +34,11 @@ 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 || ('\\' == SEPARATOR && fullPath[0] == '/'));
+ SkASSERT(fullPath[0] == SEPARATOR);
++end;
}
return SkString(fullPath, end - fullPath);
diff --git a/tests/OSPathTest.cpp b/tests/OSPathTest.cpp
index 74ca802304..22deff80a5 100644
--- a/tests/OSPathTest.cpp
+++ b/tests/OSPathTest.cpp
@@ -32,8 +32,7 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir,
// fullName should be the combined size of dir and file, plus one if
// dir did not include the final path separator.
size_t expectedSize = dir.size() + filename.size();
- if (!dir.endsWith(SkOSPath::SEPARATOR) && ('\\' != SkOSPath::SEPARATOR ||
- !dir.endsWith('/')) && !dir.isEmpty()) {
+ if (!dir.endsWith(SkOSPath::SEPARATOR) && !dir.isEmpty()) {
expectedSize++;
}
REPORTER_ASSERT(reporter, fullName.size() == expectedSize);
@@ -47,10 +46,7 @@ static void test_dir_with_file(skiatest::Reporter* reporter, SkString dir,
// dirname should be the same as dir with any trailing seperators removed.
// Except when the the string is just "/".
SkString strippedDir = dir;
- while (strippedDir.size() > 2 &&
- (strippedDir[strippedDir.size() - 1] == SkOSPath::SEPARATOR ||
- ('\\' == SkOSPath::SEPARATOR &&
- strippedDir[strippedDir.size() - 1] == '/'))) {
+ while (strippedDir.size() > 2 && strippedDir[strippedDir.size() - 1] == SkOSPath::SEPARATOR) {
strippedDir.remove(strippedDir.size() - 1, 1);
}
if (!dirname.equals(strippedDir)) {
@@ -106,13 +102,4 @@ DEF_TEST(OSPath, reporter) {
// Test that nullptr can be used for the directory and filename.
SkString emptyPath = SkOSPath::Join(nullptr, nullptr);
REPORTER_ASSERT(reporter, emptyPath.isEmpty());
-
-#ifdef SK_BUILD_FOR_WIN
- test_dir_with_file(reporter, SkString("dir/"), filename);
- test_dir_with_file(reporter, SkString("dir/dir"), filename);
- test_dir_with_file(reporter, SkString("dir\\dir/"), filename);
- test_dir_with_file(reporter, SkString("dir/dir\\"), filename);
- test_dir_with_file(reporter, SkString("dir\\dir/dir"), filename);
- test_dir_with_file(reporter, SkString("dir/dir\\dir"), filename);
-#endif
}