Almost closing bug #555105 (waiting for confirmation...)

svn-id: r4301
This commit is contained in:
Nicolas Noble 2002-05-12 21:59:03 +00:00
parent e902309d30
commit b17a510c24
3 changed files with 12 additions and 2 deletions

View File

@ -155,7 +155,7 @@ void hashconfig::merge(const hashconfig * h)
// The config-class itself.
Config::Config(const char *cfg, const char *d)
: filename(Scumm::Strdup(cfg)), domain(d ? Scumm::Strdup(d) : 0), hash(0), ndomains(0)
: filename(Scumm::Strdup(cfg)), domain(d ? Scumm::Strdup(d) : 0), hash(0), ndomains(0), willwrite(false)
{
FILE *cfg_file;
char t[MAXLINELEN];
@ -302,6 +302,9 @@ void Config::flush() const
{
FILE *cfg_file;
int i;
if (!willwrite)
return;
if (!(cfg_file = fopen(filename, "w"))) {
debug(1, "Unable to write configuration file: %s.\n", filename);
@ -377,3 +380,7 @@ void Config::merge_config(const Config * c)
}
}
}
void Config::set_writing(bool w) {
willwrite = w;
}

View File

@ -38,10 +38,12 @@ class Config {
void delete_domain(const char *);
void change_filename(const char *);
void merge_config(const Config *);
void set_writing(bool);
private:
char * filename, * domain;
hashconfig ** hash;
int ndomains;
bool willwrite;
};
// The global config object

View File

@ -230,6 +230,7 @@ void GameDetector::parseCommandLine(int argc, char **argv)
exit(1);
case 'w':
_saveconfig = true;
scummcfg->set_writing(true);
HANDLE_OPT_OPTION();
if (option != NULL)
scummcfg->change_filename(option);
@ -258,7 +259,7 @@ void GameDetector::parseCommandLine(int argc, char **argv)
}
}
if (_saveconfig)
if (_exe_name)
scummcfg->flush();
return;