2 * This file defines functions to look up file paths.
4 * Copyright (C) 2009 David Kolossa
6 * This file is part of OpenStranded.
8 * OpenStranded is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * OpenStranded is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with OpenStranded. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef STRANDED_FILESYSTEM_HH
23 #define STRANDED_FILESYSTEM_HH
49 DirectoryInfo(std::string path
);
57 FileInfo(std::string path
, int error
);
66 static std::string modName
;
73 setModName(std::string name
);
82 getUserDirectoryInfo();
85 getGameDirectoryInfo();
88 getModDirectoryInfo();
96 getSaveFileInfo(std::string name
);
99 getMapFileInfo(std::string name
);
102 // GFX files, wrappers for getGameFileInfo()
105 getGfxFileInfo(std::string name
, GfxType type
);
108 getTextureFileInfo(std::string name
);
111 getModelFileInfo(std::string name
);
114 getIconFileInfo(std::string name
);
117 getSpriteFileInfo(std::string name
);
120 getSkyFileInfo(std::string name
);
128 getSfxFileInfo(std::string name
, SfxType type
);
131 getSpeechFileInfo(std::string name
);
134 getEffectFileInfo(std::string name
);
138 * Return a vector with all files in a directory.
139 * The returned pointer to the vector needs to be freed by the
141 * @param dirPath The path of the directory
142 * @return A vector with the files of the filesystem without
145 static std::vector
<std::string
> *
146 getDirectoryVector(std::string dirPath
);
149 * Check whether a filename string with a name and an extension
150 * exists in a vector of const char*.
151 * This method is case-insensitive on Windows and case-sensitive
152 * in all other cases. The vector for the extensions also
153 * defines a priority on which element is returned. The element
154 * with the smaller index is returned when it comes to
156 * @param dirVector A pointer to a vector as returned by
157 * getDirectoryVector()
158 * @param extensions A vector with the extensions ordered by
160 * @param name The name of the file which is searched
161 * @return The matching string, "" if there is none.
164 getFileNameFromDirectoryVector(std::vector
<std::string
> *dirVector
, const std::vector
<std::string
> &extensions
, std::string name
);
167 * Check whether name has a directory in it and extract it.
168 * For example: "path/to/file" returns "path/to/".
169 * A simple "file" would return "".
172 getDirectoryPart(std::string name
);
175 * The reverse of getDirectoryPart(), this returns the file part.
176 * For example: "path/to/file" returns "file".
177 * "path/to/directory/" returns "".
180 getFilePart(std::string name
);
183 #endif /* STRANDED_FILESYSTEM_HH */