Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkOSPath.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
11
12#include <string.h>
13
14SkString SkOSPath::Join(const char *rootPath, const char *relativePath) {
15 SkString result(rootPath);
16 if (!result.endsWith(SEPARATOR) && !result.isEmpty()) {
17 result.appendUnichar(SEPARATOR);
18 }
19 result.append(relativePath);
20 return result;
21}
22
23SkString SkOSPath::Basename(const char* fullPath) {
24 if (!fullPath) {
25 return SkString();
26 }
27 const char* filename = strrchr(fullPath, SEPARATOR);
28 if (nullptr == filename) {
29 filename = fullPath;
30 } else {
31 ++filename;
32 }
33 return SkString(filename);
34}
35
36SkString SkOSPath::Dirname(const char* fullPath) {
37 if (!fullPath) {
38 return SkString();
39 }
40 const char* end = strrchr(fullPath, SEPARATOR);
41 if (nullptr == end) {
42 return SkString();
43 }
44 if (end == fullPath) {
45 SkASSERT(fullPath[0] == SEPARATOR);
46 ++end;
47 }
48 return SkString(fullPath, end - fullPath);
49}
#define SkASSERT(cond)
Definition SkAssert.h:116
static constexpr char SEPARATOR
Definition SkOSPath.h:21
static SkString Join(const char *rootPath, const char *relativePath)
Definition SkOSPath.cpp:14
static SkString Basename(const char *fullPath)
Definition SkOSPath.cpp:23
static SkString Dirname(const char *fullPath)
Definition SkOSPath.cpp:36
glong glong end
GAsyncResult * result