New option -f.
This commit is contained in:
parent
e3eadcd899
commit
67ad7ad66a
2 changed files with 19 additions and 7 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
for (i = 0; i < EF_MAX; i++) {
|
||||
if (ef_open(i, O_RDWR | O_CREAT | O_TRUNC, 0) < 0) {
|
||||
perror("ef_open");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue