[Scummvm-cvs-logs] CVS: scummvm/common config-manager.cpp,1.32,1.33
Max Horn
fingolfin at users.sourceforge.net
Fri Apr 22 11:10:20 CEST 2005
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32440
Modified Files:
config-manager.cpp
Log Message:
Use class File instead of FILE (not finished)
Index: config-manager.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-manager.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- config-manager.cpp 31 Mar 2005 05:35:03 -0000 1.32
+++ config-manager.cpp 22 Apr 2005 18:10:02 -0000 1.33
@@ -23,6 +23,7 @@
#include "stdafx.h"
#include "common/config-manager.h"
+#include "common/file.h"
#include "common/util.h"
DECLARE_SINGLETON(Common::ConfigManager);
@@ -115,9 +116,9 @@
}
void ConfigManager::loadFile(const String &filename) {
- FILE *cfg_file;
+ File cfg_file;
- if (!(cfg_file = fopen(filename.c_str(), "r"))) {
+ if (!cfg_file.open(filename.c_str())) {
warning("Unable to open configuration file: %s", filename.c_str());
} else {
char buf[MAXLINELEN];
@@ -128,16 +129,17 @@
// TODO: Detect if a domain occurs multiple times (or likewise, if
// a key occurs multiple times inside one domain).
- while (!feof(cfg_file)) {
+ while (!cfg_file.eof()) {
lineno++;
- if (!fgets(buf, MAXLINELEN, cfg_file))
- continue;
+ if (!cfg_file.readLine(buf, MAXLINELEN))
+ break;
if (buf[0] == '#') {
// Accumulate comments here. Once we encounter either the start
// of a new domain, or a key-value-pair, we associate the value
// of the 'comment' variable with that entity.
comment += buf;
+ comment += '\n';
} else if (buf[0] == '[') {
// It's a new domain which begins here.
char *p = buf + 1;
@@ -199,7 +201,6 @@
comment.clear();
}
}
- fclose(cfg_file);
}
}
More information about the Scummvm-git-logs
mailing list