diff options
author | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-05-27 20:20:42 -0700 |
---|---|---|
committer | Nicholas Feinberg <pleasingfung@gmail.com> | 2014-06-08 15:20:09 -0700 |
commit | cd69fb7288eb8b270cd3d88bacdaa19743802e27 (patch) | |
tree | 92feba4546ef2a0a3ee89c4af8e6d28f9db8e017 /crawl-ref/source/files.cc | |
parent | 4c720037b961ccf2ffb27189d220cc83b897cdb6 (diff) | |
download | crawl-ref-cd69fb7288eb8b270cd3d88bacdaa19743802e27.tar.gz crawl-ref-cd69fb7288eb8b270cd3d88bacdaa19743802e27.zip |
Remove safe_file_writer (unused)
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r-- | crawl-ref/source/files.cc | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 14b451c642..f6cf130a35 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -773,69 +773,6 @@ static void _write_ghost_version(writer &outf) marshallInt(outf, 0); } -class safe_file_writer -{ -public: - safe_file_writer(const string &filename, - const char *mode = "wb", - bool _lock = false) - : target_filename(filename), tmp_filename(target_filename), - filemode(mode), lock(_lock), filep(NULL) - { - tmp_filename = target_filename + ".tmp"; - } - - ~safe_file_writer() - { - close(); - if (tmp_filename != target_filename) - { - if (rename_u(tmp_filename.c_str(), target_filename.c_str())) - { - end(1, true, "failed to rename %s -> %s", - tmp_filename.c_str(), target_filename.c_str()); - } - } - } - - FILE *open() - { - if (!filep) - { - filep = (lock? lk_open(filemode, tmp_filename) - : fopen_u(tmp_filename.c_str(), filemode)); - if (!filep) - { - end(-1, true, - "Failed to open \"%s\" (%s; locking:%s)", - tmp_filename.c_str(), - filemode, - lock? "YES" : "no"); - } - } - return filep; - } - - void close() - { - if (filep) - { - if (lock) - lk_close(filep, tmp_filename); - else - fclose(filep); - filep = NULL; - } - } - -private: - string target_filename, tmp_filename; - const char *filemode; - bool lock; - - FILE *filep; -}; - static void _write_tagged_chunk(const string &chunkname, tag_type tag) { writer outf(you.save, chunkname); |