Crossfire Server, Trunk  R20513
Macros | Functions
output_file.c File Reference
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "global.h"
#include "logger.h"
#include "output_file.h"
Include dependency graph for output_file.c:

Go to the source code of this file.

Macros

#define TMP_EXT   ".tmp"
 The extension for temporary files that is appended to the original output filename during write operations. More...
 

Functions

void of_cancel (OutputFile *of)
 Cancels a save process. More...
 
int of_close (OutputFile *of)
 Closes an output file. More...
 
FILE * of_open (OutputFile *of, const char *fname)
 Opens an output file. More...
 

Macro Definition Documentation

#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.

Referenced by of_open().

Function Documentation

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().

Parameters
ofthe 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().

Here is the caller graph for this function:

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().

Parameters
ofthe output file instance to operate on
Returns
whether writing was successful; if unsuccessful an error message has been printed and the original file content are unchanged

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
ofan OutputFile instance allocated by the caller; it must not be freed or reused until of_close() has been called
fnamethe filename to open; the string may be freed or reused afterwards
Returns
the file pointer or 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().

Here is the call graph for this function:

Here is the caller graph for this function: