1/*
2 * Copyright 2016 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#ifndef SkOSPath_DEFINED
9#define SkOSPath_DEFINED
10
11#include "include/core/SkString.h"
12
13/**
14 * Functions for modifying SkStrings which represent paths on the filesystem.
15 */
16class SkOSPath {
17public:
18#ifdef _WIN32
19 const static char SEPARATOR = '\\';
20#else
21 const static char SEPARATOR = '/';
22#endif
23
24 /**
25 * Assembles rootPath and relativePath into a single path, like this:
26 * rootPath/relativePath.
27 * It is okay to call with a NULL rootPath and/or relativePath. A path
28 * separator will still be inserted.
29 *
30 * Uses SkPATH_SEPARATOR, to work on all platforms.
31 */
32 static SkString Join(const char* rootPath, const char* relativePath);
33
34 /**
35 * Return the name of the file, ignoring the directory structure.
36 * Behaves like python's os.path.basename. If the fullPath is
37 * /dir/subdir/, an empty string is returned.
38 * @param fullPath Full path to the file.
39 * @return SkString The basename of the file - anything beyond the
40 * final slash, or the full name if there is no slash.
41 */
42 static SkString Basename(const char* fullPath);
43
44 /**
45 * Given a qualified file name returns the directory.
46 * Behaves like python's os.path.dirname. If the fullPath is
47 * /dir/subdir/ the return will be /dir/subdir/
48 * @param fullPath Full path to the file.
49 * @return SkString The dir containing the file - anything preceding the
50 * final slash, or the full name if ending in a slash.
51 */
52 static SkString Dirname(const char* fullPath);
53};
54
55#endif
56