Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
SkOSPath Class Reference

#include <SkOSPath.h>

Static Public Member Functions

static SkString Join (const char *rootPath, const char *relativePath)
 
static SkString Basename (const char *fullPath)
 
static SkString Dirname (const char *fullPath)
 

Static Public Attributes

static constexpr char SEPARATOR = '/'
 

Detailed Description

Functions for modifying SkStrings which represent paths on the filesystem.

Definition at line 16 of file SkOSPath.h.

Member Function Documentation

◆ Basename()

SkString SkOSPath::Basename ( const char *  fullPath)
static

Return the name of the file, ignoring the directory structure. Behaves like python's os.path.basename. If the fullPath is /dir/subdir/, an empty string is returned.

Parameters
fullPathFull path to the file.
Returns
SkString The basename of the file - anything beyond the final slash, or the full name if there is no slash.

Definition at line 23 of file SkOSPath.cpp.

23 {
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}
static constexpr char SEPARATOR
Definition SkOSPath.h:21

◆ Dirname()

SkString SkOSPath::Dirname ( const char *  fullPath)
static

Given a qualified file name returns the directory. Behaves like python's os.path.dirname. If the fullPath is /dir/subdir/ the return will be /dir/subdir/

Parameters
fullPathFull path to the file.
Returns
SkString The dir containing the file - anything preceding the final slash, or the full name if ending in a slash.

Definition at line 36 of file SkOSPath.cpp.

36 {
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
glong glong end

◆ Join()

SkString SkOSPath::Join ( const char *  rootPath,
const char *  relativePath 
)
static

Assembles rootPath and relativePath into a single path, like this: rootPath/relativePath. It is okay to call with a NULL rootPath and/or relativePath. A path separator will still be inserted.

Uses SkPATH_SEPARATOR, to work on all platforms.

Definition at line 14 of file SkOSPath.cpp.

14 {
15 SkString result(rootPath);
16 if (!result.endsWith(SEPARATOR) && !result.isEmpty()) {
17 result.appendUnichar(SEPARATOR);
18 }
19 result.append(relativePath);
20 return result;
21}
GAsyncResult * result

Member Data Documentation

◆ SEPARATOR

constexpr char SkOSPath::SEPARATOR = '/'
staticconstexpr

Definition at line 21 of file SkOSPath.h.


The documentation for this class was generated from the following files: