Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/utils/SkOSPath.cpp
Line
Count
Source (jump to first uncovered line)
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
8
#include "src/utils/SkOSPath.h"
9
10
25
SkString SkOSPath::Join(const char *rootPath, const char *relativePath) {
11
25
    SkString result(rootPath);
12
25
    if (!result.endsWith(SEPARATOR) && !result.isEmpty()) {
13
25
        result.appendUnichar(SEPARATOR);
14
25
    }
15
25
    result.append(relativePath);
16
25
    return result;
17
25
}
18
19
0
SkString SkOSPath::Basename(const char* fullPath) {
20
0
    if (!fullPath) {
21
0
        return SkString();
22
0
    }
23
0
    const char* filename = strrchr(fullPath, SEPARATOR);
24
0
    if (nullptr == filename) {
25
0
        filename = fullPath;
26
0
    } else {
27
0
        ++filename;
28
0
    }
29
0
    return SkString(filename);
30
0
}
31
32
0
SkString SkOSPath::Dirname(const char* fullPath) {
33
0
    if (!fullPath) {
34
0
        return SkString();
35
0
    }
36
0
    const char* end = strrchr(fullPath, SEPARATOR);
37
0
    if (nullptr == end) {
38
0
        return SkString();
39
0
    }
40
0
    if (end == fullPath) {
41
0
        SkASSERT(fullPath[0] == SEPARATOR);
42
0
        ++end;
43
0
    }
44
0
    return SkString(fullPath, end - fullPath);
45
0
}