Crossfire Server, Trunk
|
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "global.h"
#include "logger.h"
#include "output_file.h"
Go to the source code of this file.
Macros | |
#define | TMP_EXT ".tmp" |
Functions | |
void | of_cancel (OutputFile *of) |
int | of_close (OutputFile *of) |
FILE * | of_open (OutputFile *of, const char *fname) |
#define TMP_EXT ".tmp" |
The extension for temporary files that is appended to the original output filename during write operations.
Definition at line 27 of file output_file.c.
void of_cancel | ( | OutputFile * | of | ) |
Cancels a save process. This closes and deletes the temporary file, leaving the original file contents unmodified. This function (or on_close()} must be called exactly once for each successful call to op_open().
of | the output file instance to operate on |
Definition at line 89 of file output_file.c.
References OutputFile::file, OutputFile::fname, and OutputFile::fname_tmp.
Referenced by save_map().
int of_close | ( | OutputFile * | of | ) |
Closes an output file. This function (or of_cancel()} must be called exactly once for each successful call to of_open().
of | the output file instance to operate on |
Definition at line 61 of file output_file.c.
References OutputFile::file, OutputFile::fname, OutputFile::fname_tmp, llevError, and LOG().
Referenced by account_char_save(), accounts_save(), hiscore_save(), knowledge_write_player_data(), quest_write_player_data(), resurrect_player(), save_map(), save_player(), write_book_archive(), write_map_log(), and write_todclock().
FILE* of_open | ( | OutputFile * | of, |
const char * | fname | ||
) |
Opens an output file. It is equivalent to fopen(fname, "w");
but uses a temporary file instead of fname
until of_close() is called.
of | an OutputFile instance allocated by the caller; it must not be freed or reused until of_close() has been called |
fname | the filename to open; the string may be freed or reused afterwards |
NULL
if the file could not be opened; in this case an error message has been printed and the original file content are unchanged Definition at line 30 of file output_file.c.
References OutputFile::file, OutputFile::fname, OutputFile::fname_tmp, llevError, LOG(), strdup_local, and TMP_EXT.
Referenced by account_char_save(), accounts_save(), hiscore_save(), knowledge_write_player_data(), quest_write_player_data(), resurrect_player(), save_map(), save_player(), write_book_archive(), write_map_log(), and write_todclock().