1 // $Id: path_manager.cxx,v 1.1 2003/07/25 11:07:44 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.
22 #include "globals.hxx"
23 #include "path_manager.hxx"
25 PathManager path_manager
;
27 PathManager::PathManager ()
32 PathManager::~PathManager ()
37 PathManager::add_path (const std::string
& path
)
39 path_list
.push_back (path
);
43 PathManager::complete (const std::string
& relative_path
)
45 std::string comp_path
= base_path
+ "/" + relative_path
;
51 PathManager::find_path (const std::list
<std::string
>& file_list
)
53 for (PathIter i
= path_list
.begin (); !path_found
&& i
!= path_list
.end (); ++i
)
55 bool found_file
= true;
56 for (PathIter f
= file_list
.begin (); found_file
&& f
!= file_list
.end (); ++f
)
58 if (!(access((*i
+ "/" + *f
).c_str(), R_OK
) == 0))
66 std::cout
<< "PathManager: Using base_path: " << base_path
<< std::endl
;
72 std::cout
<< "PathManager: No base path found" << std::endl
;
77 /** Search for a path which contains the file 'file' */
79 PathManager::find_path (const std::string
& file
)
81 for (PathIter i
= path_list
.begin (); !path_found
&& i
!= path_list
.end (); ++i
)
83 if ((access((*i
+ "/" + file
).c_str(), R_OK
) == 0))
88 std::cout
<< "PathManager: Using base_path: " << base_path
<< std::endl
;
94 std::cout
<< "PathManager: No base path found" << std::endl
;
100 PathManager::set_path (const std::string
& path
)