New option -f.

This commit is contained in:
Markus Armbruster 2004-03-09 14:38:59 +00:00
parent e3eadcd899
commit 67ad7ad66a
2 changed files with 19 additions and 7 deletions

View file

@ -7,6 +7,9 @@ files \- Empire file initialization
[ [
.BI \-e\ configfile .BI \-e\ configfile
] ]
[
.BI \-f
]
.br .br
.SH DESCRIPTION .SH DESCRIPTION
.I files .I files
@ -22,3 +25,6 @@ causes
to use the game configuration specified in to use the game configuration specified in
.I configfile .I configfile
(by default, the file "econfig" in the data directory is used) (by default, the file "econfig" in the data directory is used)
.TP
.BI \-f
Clobber existing game data without asking for confirmation.

View file

@ -82,13 +82,17 @@ main(int argc, char *argv[])
extern char *optarg; extern char *optarg;
int opt; int opt;
char *config_file = NULL; char *config_file = NULL;
int force = 0;
#if !defined(_WIN32) #if !defined(_WIN32)
while ((opt = getopt(argc, argv, "e:")) != EOF) { while ((opt = getopt(argc, argv, "e:f")) != EOF) {
switch (opt) { switch (opt) {
case 'e': case 'e':
config_file = optarg; config_file = optarg;
break; break;
case 'f':
force = 1;
break;
} }
} }
#endif #endif
@ -111,12 +115,14 @@ main(int argc, char *argv[])
printf("Can't make game directory\n"); printf("Can't make game directory\n");
exit(1); 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); datadir);
printf("continue? "); printf("continue? ");
fgets(buf, sizeof(buf) - 1, stdin); fgets(buf, sizeof(buf) - 1, stdin);
if (*buf != 'y' && *buf != 'Y') if (*buf != 'y' && *buf != 'Y')
exit(1); exit(1);
}
for (i = 0; i < EF_MAX; i++) { for (i = 0; i < EF_MAX; i++) {
if (ef_open(i, O_RDWR | O_CREAT | O_TRUNC, 0) < 0) { if (ef_open(i, O_RDWR | O_CREAT | O_TRUNC, 0) < 0) {
perror("ef_open"); perror("ef_open");