From 7218e3bd4616d4706090ec47d72845a2bb89c6a3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 4 May 2008 22:30:49 +0000 Subject: split map reading from models --- src/filesystem/inifile.cc | 8 +++++--- src/filesystem/inifile.h | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/filesystem') diff --git a/src/filesystem/inifile.cc b/src/filesystem/inifile.cc index d9f2839..337cf45 100644 --- a/src/filesystem/inifile.cc +++ b/src/filesystem/inifile.cc @@ -16,7 +16,7 @@ IniFile::IniFile() {} IniFile::~IniFile() {} -void IniFile::open(std::string const & name) { +bool IniFile::open(std::string const & name) { last_read_was_section = false; last_read_was_key = false; @@ -32,7 +32,7 @@ void IniFile::open(std::string const & name) { filesystem::File *f = filesystem::open(inifile_name.c_str()); if (!f) { con_warn << "Could not open " << inifile_name << std::endl; - return; + return false; } std::string fn = f->path(); @@ -42,8 +42,10 @@ void IniFile::open(std::string const & name) { inifile_ifs.open(fn.c_str()); if (!inifile_ifs.is_open()) { con_warn << "Could not stream " << fn << "!\n"; - return; + return false; } + + return true; } diff --git a/src/filesystem/inifile.h b/src/filesystem/inifile.h index 6503053..f5c903d 100644 --- a/src/filesystem/inifile.h +++ b/src/filesystem/inifile.h @@ -24,13 +24,14 @@ namespace filesystem { class IniFile { public: IniFile(); - virtual ~IniFile(); + ~IniFile(); /// open the file for reading /** the filename will get the "ini/" prefix and ".ini" suffix */ - virtual void open(std::string const & name); + bool open(std::string const & name); + /// parse one line, returns false on end-of-file bool getline(); /// current section label -- cgit v1.2.3