1
// $Id: path_manager.cxx,v 1.5 2003/04/13 23:33:19 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 2
9
// of the License, or (at your option) any later version.
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. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "globals.hxx"
22
#include "path_manager.hxx"
25
PathManager path_manager;
27
PathManager::PathManager ()
32
PathManager::~PathManager ()
37
PathManager::add_path (const std::string& path)
39
pout(PINGUS_DEBUG_PATHMGR) << "PathManager: add_path: " << path << std::endl;
40
path_list.push_back (path);
44
PathManager::complete (const std::string& relative_path)
46
std::string comp_path = base_path + "/" + relative_path;
47
pout(PINGUS_DEBUG_PATHMGR) << "PathManager: " << relative_path << " -> " << comp_path << std::endl;
53
PathManager::find_path (const std::list<std::string>& file_list)
55
for (PathIter i = path_list.begin (); !path_found && i != path_list.end (); ++i)
57
bool found_file = true;
58
for (PathIter f = file_list.begin (); found_file && f != file_list.end (); ++f)
60
if (!System::exist(*i + "/" + *f))
68
pout(PINGUS_DEBUG_PATHMGR) << "PathManager: Using base_path: " << base_path << std::endl;
74
pout(PINGUS_DEBUG_PATHMGR) << "PathManager: No base path found" << std::endl;
79
/** Search for a path which contains the file 'file' */
81
PathManager::find_path (const std::string& file)
83
for (PathIter i = path_list.begin (); !path_found && i != path_list.end (); ++i)
85
if (System::exist(*i + "/" + file))
90
pout(PINGUS_DEBUG_PATHMGR) << "PathManager: Using base_path: " << base_path << std::endl;
96
pout(PINGUS_DEBUG_PATHMGR) << "PathManager: No base path found" << std::endl;
102
PathManager::set_path (const std::string& path)