3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "pathconfig.h"
26 #include <sys/types.h>
33 dirExists(std::string const &path)
36 return (stat(path.c_str(), &st)!=-1 &&
40 Vserver::Vserver(std::string const &str) :
41 conf_dir_(str), vdir_(str), name_(str)
45 if (!dirExists(vdir_)) {
50 rpmdb_path_ = conf_dir_;
51 rpmdb_path_ += "/apps/pkgmgmt/rpmstate";
53 if (!dirExists(rpmdb_path_)) {
54 rpmdb_path_ = conf_dir_;
55 rpmdb_path_ += "/apps/pkgmgmt/base/rpm/state";
58 if (!dirExists(rpmdb_path_)) {
60 rpmdb_path_ += "/var/lib/rpm";
63 std::string tmp = conf_dir_;
66 std::ifstream name_file(tmp.c_str());
68 if (name_file.good()) getline(name_file, name_);
72 operator << (std::ostream &lhs, Vserver const &rhs)
74 return lhs << rhs.getName();