Binary File Access
[Utilities]
Detailed Description
- These functions are very usefull for reading/writing binary files that have headers or data that have to be converted depending on the current CPU byte order. It can invert 2, 4 or 8 bytes numbers to/from little/big-endian orders.
- It will process the data only if the file format is diferent from the current CPU.
- Can read from disk or memory. In case of a memory buffer, the file name must be the imBinMemoryFileName structure.
- See im_binfile.h
Data Structures | |
struct | _imBinMemoryFileName |
Memory File I/O Filename. More... | |
Typedefs | |
typedef _imBinMemoryFileName | imBinMemoryFileName |
Enumerations | |
enum | imBinFileModule { IM_RAWFILE, IM_STREAM, IM_MEMFILE, IM_SUBFILE, IM_FILEHANDLE, IM_IOCUSTOM0 } |
Functions | |
imBinFile * | imBinFileOpen (const char *pFileName) |
imBinFile * | imBinFileNew (const char *pFileName) |
void | imBinFileClose (imBinFile *bfile) |
int | imBinFileError (imBinFile *bfile) |
unsigned long | imBinFileSize (imBinFile *bfile) |
int | imBinFileByteOrder (imBinFile *bfile, int pByteOrder) |
unsigned long | imBinFileRead (imBinFile *bfile, void *pValues, unsigned long pCount, int pSizeOf) |
unsigned long | imBinFileWrite (imBinFile *bfile, void *pValues, unsigned long pCount, int pSizeOf) |
unsigned long | imBinFilePrintf (imBinFile *bfile, char *format,...) |
void | imBinFileSeekTo (imBinFile *bfile, unsigned long pOffset) |
void | imBinFileSeekOffset (imBinFile *bfile, long pOffset) |
void | imBinFileSeekFrom (imBinFile *bfile, long pOffset) |
unsigned long | imBinFileTell (imBinFile *bfile) |
int | imBinFileEndOfFile (imBinFile *bfile) |
int | imBinFileSetCurrentModule (int pModule) |
Typedef Documentation
|
Memory File I/O Filename.
|
Enumeration Type Documentation
|
Predefined I/O Modules.
00103 { 00104 IM_RAWFILE, /**< System dependent file I/O Rotines. */ 00105 IM_STREAM, /**< Standard Ansi C Stream I/O Rotines. */ 00106 IM_MEMFILE, /**< Uses a memory buffer. */ 00107 IM_SUBFILE, /**< It is a sub file. FileName is a imBinFile* pointer from any other module. */ 00108 IM_FILEHANDLE,/**< System dependent file I/O Rotines, but FileName is a system file handle ("int" in UNIX and "HANDLE" in Windows). */ 00109 IM_IOCUSTOM0 /**< Other registered modules starts from here. */ 00110 };
|
Function Documentation
|
Opens an existant binary file for reading. The default file byte order is the CPU byte order. Returns NULL if failed. |
|
Creates a new binary file for writing. The default file byte order is the CPU byte order. Returns NULL if failed. |
|
Closes the file. |
|
Indicates that was an error on the last operation. |
|
Returns the file size in bytes. |
|
Changes the file byte order. Returns the old one. |
|
Reads an array of count values with byte sizes: 1, 2, 4, or 8. And invert the byte order if necessary after read. |
|
Writes an array of values with sizes: 1, 2, 4, or 8. And invert the byte order if necessary before write. |
|
Writes a string without the NULL terminator. The function uses sprintf to compose the string. |
|
Moves the file pointer from the begining of the file. |
|
Moves the file pointer from current position. |
|
Moves the file pointer from the end of the file. |
|
Returns the current offset position. |
|
Indicates that the file pointer is at the end of the file. |
|
Sets the current I/O module.
|