skia2/src/utils/SkOSPath.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

46 lines
1.1 KiB
C++

/*
* 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"
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);
}