15 #include "streamWrapper.h" 29 #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) 31 (*global_operator_delete)(_istream);
47 read(
char *buffer, streamsize num_bytes) {
50 _istream->read(buffer, num_bytes);
51 streamsize read_bytes = _istream->gcount();
52 while (read_bytes < num_bytes) {
59 _istream->read(buffer + read_bytes, num_bytes - read_bytes);
60 streamsize this_read_bytes = _istream->gcount();
61 assert(this_read_bytes <= num_bytes - read_bytes);
62 read_bytes += this_read_bytes;
64 if (this_read_bytes == 0) {
66 memset(buffer + read_bytes, 0, num_bytes - read_bytes);
70 assert(read_bytes <= num_bytes);
81 read(
char *buffer, streamsize num_bytes, streamsize &read_bytes) {
84 _istream->read(buffer, num_bytes);
85 read_bytes = _istream->gcount();
86 assert(read_bytes <= num_bytes);
99 read(
char *buffer, streamsize num_bytes, streamsize &read_bytes,
bool &eof) {
102 _istream->read(buffer, num_bytes);
103 read_bytes = _istream->gcount();
104 assert(read_bytes <= num_bytes);
105 eof = _istream->eof() || _istream->fail();
119 seek_read(streamsize pos,
char *buffer, streamsize num_bytes,
120 streamsize &read_bytes,
bool &eof) {
123 _istream->seekg(pos);
124 _istream->read(buffer, num_bytes);
125 read_bytes = _istream->gcount();
126 assert(read_bytes <= num_bytes);
127 eof = _istream->eof() || _istream->fail();
143 _istream->seekg(0, ios::end);
144 pos = _istream->tellg();
162 #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) 163 _ostream->~ostream();
164 (*global_operator_delete)(_ostream);
178 write(
const char *buffer, streamsize num_bytes) {
180 _ostream->write(buffer, num_bytes);
192 write(
const char *buffer, streamsize num_bytes,
bool &fail) {
195 _ostream->write(buffer, num_bytes);
196 fail = _ostream->fail();
209 seek_write(streamsize pos,
const char *buffer, streamsize num_bytes,
213 _ostream->seekp(pos);
216 if (_ostream->fail() && _stringstream_hack && pos == 0) {
223 _ostream->write(buffer, num_bytes);
224 fail = _ostream->fail();
239 _ostream->seekp(0, ios::end);
242 if (_ostream->fail() && _stringstream_hack) {
249 _ostream->write(buffer, num_bytes);
250 fail = _ostream->fail();
266 _ostream->seekp(0, ios::end);
269 if (_ostream->fail() && _stringstream_hack) {
278 pos = _ostream->tellp();
296 #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) 297 _iostream->~iostream();
298 (*global_operator_delete)(_iostream);
void seek_write(streamsize pos, const char *buffer, streamsize num_bytes, bool &fail)
Atomically seeks to a particular offset from the beginning of the file, and writes a number of bytes ...
void seek_eof_write(const char *buffer, streamsize num_bytes, bool &fail)
Atomically seeks to the end of the file, and writes a number of bytes to the stream.
void write(const char *buffer, streamsize num_bytes)
Atomically writes a number of bytes to the stream, without error detection.
void seek_read(streamsize pos, char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof)
Atomically seeks to a particular offset from the beginning of the file, and reads a number of bytes f...
void release()
Releases the internal lock.
streamsize seek_gpos_eof()
Atomically seeks to EOF and returns the gpos there; that is, returns the file size.
streamsize seek_ppos_eof()
Atomically seeks to EOF and returns the ppos there; that is, returns the file size.
void read(char *buffer, streamsize num_bytes)
Atomically reads a number of bytes from the stream, without error detection.
void acquire()
Acquires the internal lock.