| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#if !defined( _FILE_STREAM_H ) |
| 23 |
#define _FILE_STREAM_H |
| 24 |
|
| 25 |
#include "common.h" |
| 26 |
|
| 27 |
#if defined( HAVE_GLIB_H ) |
| 28 |
#include <glib.h> |
| 29 |
#include <glib/gstdio.h> |
| 30 |
#endif |
| 31 |
|
| 32 |
#include <stdio.h> |
| 33 |
|
| 34 |
#if defined( __cplusplus ) |
| 35 |
extern "C" { |
| 36 |
#endif |
| 37 |
|
| 38 |
#define FILE_STREAM_OPEN_APPEND "a" |
| 39 |
#define FILE_STREAM_OPEN_READ "r" |
| 40 |
#define FILE_STREAM_OPEN_WRITE "w" |
| 41 |
|
| 42 |
#if defined( WINAPI ) |
| 43 |
#define FILE_STREAM_BINARY_OPEN_APPEND "ab" |
| 44 |
#define FILE_STREAM_BINARY_OPEN_READ "rb" |
| 45 |
#define FILE_STREAM_BINARY_OPEN_WRITE "wb" |
| 46 |
|
| 47 |
#else |
| 48 |
#define FILE_STREAM_BINARY_OPEN_APPEND "a" |
| 49 |
#define FILE_STREAM_BINARY_OPEN_READ "r" |
| 50 |
#define FILE_STREAM_BINARY_OPEN_WRITE "w" |
| 51 |
|
| 52 |
#endif |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
#if defined( HAVE_GLIB_H ) |
| 57 |
#define file_stream_open( filename, mode ) \ |
| 58 |
g_fopen( filename, mode ) |
| 59 |
|
| 60 |
#elif defined( HAVE_FOPEN ) || defined( WINAPI ) |
| 61 |
#define file_stream_open( filename, mode ) \ |
| 62 |
fopen( filename, mode ) |
| 63 |
#endif |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
#if defined( WINAPI ) |
| 68 |
#define file_stream_open_wide( filename, mode ) \ |
| 69 |
_wfopen( filename, mode ) |
| 70 |
#endif |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
#if defined( HAVE_FCLOSE ) || defined( WINAPI ) |
| 75 |
#define file_stream_close( stream ) \ |
| 76 |
fclose( stream ) |
| 77 |
#endif |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
#if defined( HAVE_FREAD ) || defined( WINAPI ) |
| 82 |
#define file_stream_read( stream, data, size ) \ |
| 83 |
fread( data, 1, size, stream ) |
| 84 |
#endif |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
#if defined( HAVE_FWRITE ) || defined( WINAPI ) |
| 89 |
#define file_stream_write( stream, data, size ) \ |
| 90 |
fwrite( data, 1, size, stream ) |
| 91 |
#endif |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
#if defined( WINAPI ) |
| 96 |
#define file_stream_seek_offset( stream, offset, whence ) \ |
| 97 |
fseek( stream, offset, whence ) |
| 98 |
|
| 99 |
#elif defined( HAVE_FSEEKO ) |
| 100 |
#define file_stream_seek_offset( stream, offset, whence ) \ |
| 101 |
fseeko( stream, offset, whence ) |
| 102 |
|
| 103 |
#elif defined( HAVE_FSEEKO64 ) |
| 104 |
#define file_stream_seek_offset( stream, offset, whence ) \ |
| 105 |
fseeko64( stream, offset, whence ) |
| 106 |
#endif |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
#if defined( HAVE_FEOF ) || defined( WINAPI ) |
| 111 |
#define file_stream_at_end( stream ) \ |
| 112 |
feof( stream ) |
| 113 |
#endif |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
#if defined( HAVE_FGETS ) || defined( WINAPI ) |
| 118 |
#define file_stream_get_string( stream, string, size ) \ |
| 119 |
fgets( string, size, stream ) |
| 120 |
#endif |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
#if defined( HAVE_FGETWS ) || defined( WINAPI ) |
| 125 |
#define file_stream_get_string_wide( stream, string, size ) \ |
| 126 |
fgetws( string, size, stream ) |
| 127 |
#endif |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
#if defined( HAVE_GLIB_H ) |
| 132 |
#define file_stream_vfprintf( stream, format, ... ) \ |
| 133 |
g_vfprintf( stream, format, __VA_ARGS__ ) |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
#elif defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) |
| 138 |
#define file_stream_vfprintf \ |
| 139 |
vfprintf |
| 140 |
|
| 141 |
#elif defined( HAVE_VFPRINTF ) || defined( WINAPI ) |
| 142 |
#define file_stream_vfprintf( stream, format, ... ) \ |
| 143 |
vfprintf( stream, format, __VA_ARGS__ ) |
| 144 |
#endif |
| 145 |
|
| 146 |
#if defined( __cplusplus ) |
| 147 |
} |
| 148 |
#endif |
| 149 |
|
| 150 |
#endif |
| 151 |
|