1 /* Dungeon Master --- RPG Adventure Generator
2 Copyright © 2019 Javier Sancho <jsf@jsancho.org>
4 Dungeon Master is free software; you can redistribute it and/or modify it
5 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.
9 Dungeon Master is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Dungeon Master. If not, see <http://www.gnu.org/licenses/>.
21 std::string get_exec_path ()
24 size_t len = sizeof (pBuf);
27 sprintf (szTmp, "/proc/%d/exe", getpid ());
28 int bytes = readlink (szTmp, pBuf, len);
34 std::string exec_path = pBuf;
35 return exec_path.substr (0, exec_path.rfind (PATH_DELIM) + 1);
38 std::string get_home_path ()
40 return (std::string) getenv ("HOME") + PATH_DELIM + "." + PROGRAM_NAME;
43 std::set<std::string> get_dmaster_paths () {
44 std::set<std::string> paths;
45 paths.insert (get_exec_path ());
46 paths.insert (DATA_PATH);
47 paths.insert (get_home_path ());