IWAVE File Management Functions

Interface to standard C i/o.

Creates database of filenames and associated FILE*s. ALWAYS use in place of fopen in all iwave apps. Associates file pointers to file names for the life of the process. Since many file types are structured after prototypes, also records prototype information. The fopen interface iwave_fopen searches for file in list of already-opened files for given name, mode, prototype, and temp status, returns pointer assigned to file if found, otherwise opens file and returns file pointer with appropriate mode set.

Files are either temp or archival. Temp files treated differently from archival files. Temp files may be re-used or overwritten when current use is finished, for which purpose the database flags temp status. Indicate temp status by setting *name=NULL on call to iwave_fopen - in that case, on (successful) return, reassigns this pointer to a copy of a character string generated by mkstemp. Passing a non-NULL char * indicates archival status of the file - the string passed is the name of the file opened, either in the current call to iwave_fopen or cached in a previous call. In either case, memory allocated for filename storage must be managed by the calling unit.

The calling app should NOT close files or reset file pointers. Once opened, files remain open until closed in the "destructor" iwave_fdestroy, which should be called only once on exit from an app process. The utility iwave_fclose marks temporary files for possible re-use, but has no effect on archival files. A temp file marked for re-use by iwave_fclose may be returned for use by another call to iwave_fopen with any access mode. However the access mode will be ignored, as iwave_fopen opens all temp files with access mode "w+". Unlike fopen, the file is truncated only on being opened the first time by iwave_fopen. Subsequent calls which return pointers to the same file (switching from inuse=0 to inuse=1, for temp files) do not truncate the existing file.


Generated on 5 Jan 2017 for IWAVEBASE by  doxygen 1.4.7