ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
path.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 //=============================================================================
23 //
24 // Platform-independent Path functions
25 //
26 //=============================================================================
27 
28 #ifndef AGS_SHARED_UTIL_PATH_H
29 #define AGS_SHARED_UTIL_PATH_H
30 
31 #include "ags/shared/util/string.h"
32 
33 #define PATH_ALT_SEPARATOR ('\\')
34 
35 namespace AGS3 {
36 namespace AGS {
37 namespace Shared {
38 
39 namespace Path {
40 
41 // Get a filename from a path
42 String get_filename(const String &path);
43 // Get an extension from a filename
44 String get_extension(const String &path);
45 
46 // Returns parent directory of the given path;
47 // returns "." (current dir) if the path does not contain a parent segment
48 String GetParent(const String &path);
49 // Returns parent directory of the given path;
50 // returns "." (current dir) if the path does not contain a parent segment
51 String GetFilename(const String &path);
52 // Returns file's extension; file may be a fully qualified path too
53 String GetFileExtension(const String &path);
54 
55 // Makes a platform-dependant path comparison.
56 // This takes into consideration platform's filename case (in)sensivity and
57 // DOS-compatible 8.3 filenames;
58 // The result value corresponds to stdlib strcmp function.
59 int ComparePaths(const String &path1, const String &path2);
60 
61 // Returns path to the actual directory, referenced by given path;
62 // if path is a directory, returns path unchanged, if path is a file, returns
63 // parent directory containing that file.
64 String GetDirectoryPath(const String &path);
65 // Tells if the path points to the parent path's location or lower directory;
66 // return FALSE if the path points to outside of the parent location.
67 bool IsSameOrSubDir(const String &parent, const String &path);
68 // Tells if the path is relative.
69 bool IsRelativePath(const String &path);
70 
71 // Makes a path have only '/' slashes; this is to make it easier to work
72 // with path, knowing it contains only one type of directory separators
73 void FixupPath(String &path);
74 // Fixups path and removes trailing slash
75 String MakePathNoSlash(const String &path);
76 // Fixups path and adds trailing slash if it's missing
77 String MakeTrailingSlash(const String &path);
78 // Converts any path to an absolute path; relative paths are assumed to
79 // refer to the current working directory.
80 String MakeAbsolutePath(const String &path);
81 // Tries to create a relative path that would point to 'path' location
82 // if walking out of the 'base'. Returns empty string on failure.
83 // NOTE: the 'base' is only considered a directory if it has a trailing slash.
84 String MakeRelativePath(const String &base, const String &path);
85 // Creates path by combining directory, file name and extension
86 String MakePath(const String &parent, const String &filename, const String &ext);
87 // Appends another section to existing path
88 String &AppendPath(String &path, const String &child);
89 // Concatenates parent and relative paths
90 String ConcatPaths(const String &parent, const String &child);
91 String ConcatPaths(String &buf, const String &parent, const String &child);
92 // Splits path into components, divided by path separator
93 std::vector<String> Split(const String &path);
94 
95 // Subsitutes illegal characters with '_'. This function uses a combined set
96 // of illegal chars from all the supported platforms to make a name that
97 // could be copied across systems without problems.
98 String FixupSharedFilename(const String &filename);
99 
100 // Converts filepath into ASCII variant; returns empty string on failure
101 String GetPathInASCII(const String &path);
102 // Converts filepath from command line's argument into ASCII variant
103 String GetCmdLinePathInASCII(const char *arg, int arg_index);
104 } // namespace Path
105 
106 } // namespace Shared
107 } // namespace AGS
108 } // namespace AGS3
109 
110 #endif
Definition: achievements_tables.h:27
Path
Definition: game.h:75
Definition: ags.h:40