Mercurial > hg > early-roguelike
diff arogue7/save.c @ 128:c697782a9b37
arogue7: implement the -n option.
author | John "Elwin" Edwards |
---|---|
date | Mon, 11 May 2015 16:46:00 -0400 |
parents | b786053d2f37 |
children | 89deb1197a2d |
line wrap: on
line diff
--- a/arogue7/save.c Mon May 11 13:36:36 2015 -0400 +++ b/arogue7/save.c Mon May 11 16:46:00 2015 -0400 @@ -63,7 +63,10 @@ mpos = 0; if (file_name[0] != '\0') { - msg("Save file (%s)? ", file_name); + if (use_savedir) + msg("Save game? "); + else + msg("Save file (%s)? ", file_name); do { c = readchar(); @@ -77,6 +80,12 @@ } } + if (use_savedir) + { + msg(""); + return FALSE; + } + do { msg("File name: "); @@ -90,7 +99,11 @@ strcpy(file_name, buf); gotfile: if ((savefd = open(file_name, O_WRONLY|O_CREAT|O_TRUNC,0666)) < 0) + { msg(strerror(errno)); /* fake perror() */ + if (use_savedir) + return FALSE; + } } while (savefd < 0); /* @@ -168,6 +181,10 @@ file = file_name; if ((inf = open(file, 0)) < 0) { + if (use_savedir && errno == ENOENT) + { + return TRUE; + } perror(file); return FALSE; }