1
/* $Id: pathname.cpp 3194 2007-09-20 21:04:35Z grumbel $
3
** Pingus - A free Lemmings clone
4
** Copyright (C) 2007 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
25
#include "path_manager.hpp"
26
#include "pathname.hpp"
28
Pathname Pathname::tmpfile(const std::string& prefix)
30
assert(!"Unimplemented");
39
Pathname::Pathname(const std::string& pathname_, Type type_)
40
: pathname(pathname_), type(type_)
45
Pathname::get_sys_path() const
53
return path_manager.complete(pathname);
59
assert(!"Never reached");
65
Pathname::get_raw_path() const
71
Pathname::get_type() const
77
Pathname::empty() const
79
return (type == INVALID);
83
Pathname::exist() const
85
return System::exist(get_sys_path());
89
Pathname::mtime() const
91
return System::get_mtime(get_sys_path());
99
case Pathname::INVALID:
100
return "invalid://" + pathname;
102
case Pathname::DATA_PATH:
103
return "datadir://" + pathname;
105
case Pathname::SYSTEM_PATH:
106
return "system://" + pathname;
109
assert(!"never reached");
111
return std::string();
114
std::ostream& operator<< (std::ostream& os, const Pathname& p)
118
case Pathname::INVALID:
119
return os << "invalid://" << p.get_raw_path();
121
case Pathname::DATA_PATH:
122
return os << "datadir://" << p.get_raw_path();
124
case Pathname::SYSTEM_PATH:
125
return os << "system://" << p.get_raw_path();
128
assert(!"never reached");