Crossfire Server, Trunk
|
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | OutputFile |
Functions | |
void | of_cancel (OutputFile *of) |
int | of_close (OutputFile *of) |
FILE * | of_open (OutputFile *of, const char *fname) |
Functions for creating text output files. During (re-)writing a new file or if a write error occurs the old file contents are still available.
Example usage:
OutputFile of; FILE *f; f = of_open(&of, "some_file.txt", llevError); if (f == NULL) return; fprintf(f, "..."); fprintf(f, "..."); if (!of_close(&of)) return;
Definition in file output_file.h.
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.cpp.
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.cpp.
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.cpp.
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().