diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-07-10 03:16:12 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-07-10 11:11:29 +0200 |
commit | 4a20bb18f0e7da910ae53b29b623e124c5de5887 (patch) | |
tree | 68c540a3c01e4fb332df674b94f00a6911afb757 /crawl-ref/source/package.cc | |
parent | 831427b3421b071c2c0cb1256088c4ade7c1620b (diff) | |
download | crawl-ref-4a20bb18f0e7da910ae53b29b623e124c5de5887.tar.gz crawl-ref-4a20bb18f0e7da910ae53b29b623e124c5de5887.zip |
An undocumented command-line option, --no-save.
It uses a temporary file for the save file. This fixes canned tests breaking
if a run has been aborted (and thus a save by that name exists), and also
allows concurrently running multiple instances of the same test.
Implies wizmode.
Diffstat (limited to 'crawl-ref/source/package.cc')
-rw-r--r-- | crawl-ref/source/package.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crawl-ref/source/package.cc b/crawl-ref/source/package.cc index be215095fb..c999abcbcd 100644 --- a/crawl-ref/source/package.cc +++ b/crawl-ref/source/package.cc @@ -125,6 +125,29 @@ package::package(const char* file, bool writeable, bool empty) } } +package::package() + : rw(true), n_users(0), dirty(false), aborted(false) +{ + dprintf("package: initializing tmp file\n"); + filename = "[tmp]"; + + char file[7] = "XXXXXX"; + fd = mkstemp(file); + if (fd == -1) + sysfail("can't create temporary save file"); + + ::unlink(file); // FIXME: won't work on Windows + + if (!lock_file(fd, true)) + { + close(fd); + sysfail("failed to lock newly created save (%s)", file); + } + + dirty = true; + file_len = sizeof(file_header); +} + void package::load() { file_header head; |