From 67ad7ad66adef51005aa1ef1b777b4213a0b98a9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 9 Mar 2004 14:38:59 +0000 Subject: [PATCH] New option -f. --- man/files.1 | 6 ++++++ src/util/files.c | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/man/files.1 b/man/files.1 index 5dda7631..4fafc128 100644 --- a/man/files.1 +++ b/man/files.1 @@ -7,6 +7,9 @@ files \- Empire file initialization [ .BI \-e\ configfile ] +[ +.BI \-f +] .br .SH DESCRIPTION .I files @@ -22,3 +25,6 @@ causes to use the game configuration specified in .I configfile (by default, the file "econfig" in the data directory is used) +.TP +.BI \-f +Clobber existing game data without asking for confirmation. diff --git a/src/util/files.c b/src/util/files.c index 738a5b40..a670c912 100644 --- a/src/util/files.c +++ b/src/util/files.c @@ -82,13 +82,17 @@ main(int argc, char *argv[]) extern char *optarg; int opt; char *config_file = NULL; - + int force = 0; + #if !defined(_WIN32) - while ((opt = getopt(argc, argv, "e:")) != EOF) { + while ((opt = getopt(argc, argv, "e:f")) != EOF) { switch (opt) { case 'e': config_file = optarg; break; + case 'f': + force = 1; + break; } } #endif @@ -111,12 +115,14 @@ main(int argc, char *argv[]) printf("Can't make game directory\n"); exit(1); } - printf("WARNING: this blasts the existing game in %s (if any)\n", + if (!force) { + printf("WARNING: this blasts the existing game in %s (if any)\n", datadir); - printf("continue? "); - fgets(buf, sizeof(buf) - 1, stdin); - if (*buf != 'y' && *buf != 'Y') - exit(1); + printf("continue? "); + fgets(buf, sizeof(buf) - 1, stdin); + if (*buf != 'y' && *buf != 'Y') + exit(1); + } for (i = 0; i < EF_MAX; i++) { if (ef_open(i, O_RDWR | O_CREAT | O_TRUNC, 0) < 0) { perror("ef_open");