]> git.pond.sub.org Git - empserver/commitdiff
New option -f.
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 9 Mar 2004 14:38:59 +0000 (14:38 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 9 Mar 2004 14:38:59 +0000 (14:38 +0000)
man/files.1
src/util/files.c

index 5dda76313ef05946d69459e4b4d648b65a0fe449..4fafc128be0061407cde61583b2bfabe8cfec7bd 100644 (file)
@@ -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.
index 738a5b401f6326ca93ac073088d9db59bc1bb959..a670c912b8c3430d2fe206da0c2e0f71f924aa14 100644 (file)
@@ -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");