iwave_fopen.h File Reference

#include "utils.h"

Go to the source code of this file.

Defines

#define UNLINK_TMPS
 if set, unlink temporary files in iwave_fdestroy

Functions

FILE * iwave_fopen (char **name, const char *mode, const char *proto, FILE *stream)
 Organized to behave exactly as fopen does with respect to mode:.
FILE * iwave_const_fopen (const char *name, const char *mode, const char *proto, FILE *stream)
 const filename version of iwave_fopen.
void iwave_fclose (FILE *fp)
 If file has temp status, flags file as not in use (does not actually close or unlink).
void iwave_fdestroy ()
 closes all files, unlinks those flagged as temporary, deallocates all memory allocated in the buildup of the file database.
void iwave_fprintall (FILE *stream)
 prints the data of the file management struct
const char * iwave_getproto (const char *name)
 returns prototype filename for given filename, or NULL if none found


Define Documentation

#define UNLINK_TMPS

if set, unlink temporary files in iwave_fdestroy

Definition at line 44 of file iwave_fopen.h.


Function Documentation

FILE* iwave_fopen ( char **  name,
const char *  mode,
const char *  proto,
FILE *  stream 
)

Organized to behave exactly as fopen does with respect to mode:.

``r'' Open text file for reading. The stream is positioned at the beginning of the file.

``r+'' Open for reading and writing. The stream is positioned at the beginning of the file.

``w'' Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file.

``w+'' Open for reading and writing. The file is created if it does not exist, otherwise it is truncated. The stream is positioned at the beginning of the file.

No use of the "a" modes is expected in IWAVE, though these should also work the same way.

Parameters:
name pointer to name (char *) of file to be opened. If name != NULL on call, then used as target filename and treated as const. If NULL on call, then assigned to a string generated by mkstemp, either new if no suitable temp file available, or name of an existing temp file if one with same prototype is not in use, on return.
mode access mode, exactly as in fopen
proto name of prototype file - NULL if no prototype exists; if assigned, guarantees that file has same internal structure as prototype. On opening a new file with an existing prototype in w or w+ mode, iwave_fopen performs byte-level copy of prototype onto target, which enforces guarantee. For r or r+ access mode, only file length is checked against prototype, as iwave_fopen has no access to any other information about internal file structure.
stream verbose output unit
Returns:
either valid file pointer, or NULL if none could be found or allocated

FILE* iwave_const_fopen ( const char *  name,
const char *  mode,
const char *  proto,
FILE *  stream 
)

const filename version of iwave_fopen.

Returns non-null FILE* only if name is non-null string, naming existing file meeting other criteria (for example, matching prototype, if one is given). Arguments, function otherwise identical to iwave_fopen.

void iwave_fclose ( FILE *  fp  ) 

If file has temp status, flags file as not in use (does not actually close or unlink).

Temp files on which iwave_fclose has been called may be reused as out-of-core workspace with the same prototype later in an application. No-op for archival file.

void iwave_fdestroy (  ) 

closes all files, unlinks those flagged as temporary, deallocates all memory allocated in the buildup of the file database.

call only once per application, on exit from the application process.

void iwave_fprintall ( FILE *  stream  ) 

prints the data of the file management struct

const char* iwave_getproto ( const char *  name  ) 

returns prototype filename for given filename, or NULL if none found


Generated on 5 Jan 2017 for IWAVEBASE by  doxygen 1.4.7