1 /* 2 * This file is part of Warzone 2100. 3 * Copyright (C) 2018-2020 Warzone 2100 Project 4 * 5 * Warzone 2100 is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * Warzone 2100 is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Warzone 2100; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef _LIB_FRAMEWORK_WZPATHS_H 21 #define _LIB_FRAMEWORK_WZPATHS_H 22 23 #include <string> 24 25 std::string getWZInstallPrefix(); 26 27 class WzPathInfo 28 { 29 private: 30 WzPathInfo(const std::string &file); 31 public: 32 // Expects a filename / path with "/" as the path separator. 33 static WzPathInfo fromPlatformIndependentPath(const std::string& file); 34 public: 35 // Returns the name of the file (excluding the path). 36 std::string fileName() const; 37 38 // Returns the file name, including the path. 39 std::string filePath() const; 40 41 // Returns the base name of the file (without the path). 42 // The base name = all characters in the file up to (but not including) the first '.' character. 43 // ex. 44 // ```cpp 45 // WzPathInfo info("/autohost/example.js"); 46 // auto result = info.baseName(); // result == "example" 47 // ``` 48 std::string baseName() const; 49 50 // Returns the file's path. Does *not* include the file name. 51 std::string path() const; 52 53 private: 54 std::string file; 55 }; 56 57 #endif // _LIB_FRAMEWORK_WZPATHS_H 58