1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2020, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 #include <string>
23 #include <vector>
24 
25 class CSystemUtils;
26 
27 /**
28  *  \class CPathManager
29  *  \brief Class for managing data/lang/save paths
30  */
31 class CPathManager
32 {
33 public:
34     CPathManager(CSystemUtils* systemUtils);
35     ~CPathManager();
36 
37     void SetDataPath(const std::string &dataPath);
38     void SetLangPath(const std::string &langPath);
39     void SetSavePath(const std::string &savePath);
40 
41     const std::string& GetDataPath();
42     const std::string& GetLangPath();
43     const std::string& GetSavePath();
44 
45     //! Checks if paths are configured correctly
46     std::string VerifyPaths();
47     //! Loads configured paths
48     void InitPaths();
49 
50     //! Adds a path to a mod
51     void AddMod(const std::string& path);
52     //! Find paths to mods in mod search directories
53     std::vector<std::string> FindMods() const;
54     //! Adds a mod search directory
55     void AddModSearchDir(const std::string &modSearchDirPath);
56 
57 private:
58     std::vector<std::string> FindModsInDir(const std::string &dir) const;
59 
60 private:
61     //! Data path
62     std::string m_dataPath;
63     //! Lang path
64     std::string m_langPath;
65     //! Save path
66     std::string m_savePath;
67     //! Mod search paths
68     std::vector<std::string> m_modSearchDirs;
69     //! Additional mod paths
70     std::vector<std::string> m_mods;
71 };
72