1 | // SuperTux |
2 | // Copyright (C) 2006 Matthias Braun <matze@braunis.de> |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | |
17 | #ifndef HEADER_SUPERTUX_UTIL_FILE_SYSTEM_HPP |
18 | #define |
19 | |
20 | #include <string> |
21 | |
22 | namespace FileSystem { |
23 | |
24 | /** Returns true if the given path is a directory */ |
25 | bool is_directory(const std::string& path); |
26 | |
27 | /** Return true if the given file exists */ |
28 | bool exists(const std::string& path); |
29 | |
30 | /** Create the given directory */ |
31 | void mkdir(const std::string& directory); |
32 | |
33 | /** returns the path of the directory the file is in */ |
34 | std::string dirname(const std::string& filename); |
35 | |
36 | /** returns the name of the file */ |
37 | std::string basename(const std::string& filename); |
38 | |
39 | /** Return a path to 'filename' that is relative to 'basedir', e.g. |
40 | reldir("/levels/juser/level1.stl", "/levels") -> "juser/level1.stl" */ |
41 | std::string relpath(const std::string& filename, const std::string& basedir); |
42 | |
43 | /** remove everything starting from and including the last dot */ |
44 | std::string strip_extension(const std::string& filename); |
45 | |
46 | /** normalize filename so that "blup/bla/blo/../../bar" will become |
47 | "blup/bar" */ |
48 | std::string normalize(const std::string& filename); |
49 | |
50 | /** join two filenames join("foo", "bar") -> "foo/bar" */ |
51 | std::string join(const std::string& lhs, const std::string& rhs); |
52 | |
53 | /** Remove a file |
54 | @return true when successfully removed, false otherwise */ |
55 | bool remove(const std::string& path); |
56 | |
57 | /** Opens a file path or an address outside of SuperTux |
58 | * @param path path or URL to open |
59 | */ |
60 | void open_path(const std::string& path); |
61 | |
62 | } // namespace FileSystem |
63 | |
64 | #endif |
65 | |
66 | /* EOF */ |
67 | |