16 using std::streamsize;
28 #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) 30 (*global_operator_delete)(_istream);
43 read(
char *buffer, streamsize num_bytes) {
46 _istream->read(buffer, num_bytes);
47 streamsize read_bytes = _istream->gcount();
48 while (read_bytes < num_bytes) {
54 _istream->read(buffer + read_bytes, num_bytes - read_bytes);
55 streamsize this_read_bytes = _istream->gcount();
56 assert(this_read_bytes <= num_bytes - read_bytes);
57 read_bytes += this_read_bytes;
59 if (this_read_bytes == 0) {
61 memset(buffer + read_bytes, 0, num_bytes - read_bytes);
65 assert(read_bytes <= num_bytes);
74 read(
char *buffer, streamsize num_bytes, streamsize &read_bytes) {
77 _istream->read(buffer, num_bytes);
78 read_bytes = _istream->gcount();
79 assert(read_bytes <= num_bytes);
89 read(
char *buffer, streamsize num_bytes, streamsize &read_bytes,
bool &eof) {
92 _istream->read(buffer, num_bytes);
93 read_bytes = _istream->gcount();
94 assert(read_bytes <= num_bytes);
95 eof = _istream->eof() || _istream->fail();
105 seek_read(streamsize pos,
char *buffer, streamsize num_bytes,
106 streamsize &read_bytes,
bool &eof) {
109 _istream->seekg(pos);
110 _istream->read(buffer, num_bytes);
111 read_bytes = _istream->gcount();
112 assert(read_bytes <= num_bytes);
113 eof = _istream->eof() || _istream->fail();
126 _istream->seekg(0, std::ios::end);
127 pos = _istream->tellg();
143 #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) 144 _ostream->~ostream();
145 (*global_operator_delete)(_ostream);
155 void OStreamWrapper::
156 write(
const char *buffer, streamsize num_bytes) {
158 _ostream->write(buffer, num_bytes);
166 void OStreamWrapper::
167 write(
const char *buffer, streamsize num_bytes,
bool &fail) {
170 _ostream->write(buffer, num_bytes);
171 fail = _ostream->fail();
181 seek_write(streamsize pos,
const char *buffer, streamsize num_bytes,
185 _ostream->seekp(pos);
188 if (_ostream->fail() && _stringstream_hack && pos == 0) {
195 _ostream->write(buffer, num_bytes);
196 fail = _ostream->fail();
209 _ostream->seekp(0, std::ios::end);
212 if (_ostream->fail() && _stringstream_hack) {
219 _ostream->write(buffer, num_bytes);
220 fail = _ostream->fail();
233 _ostream->seekp(0, std::ios::end);
236 if (_ostream->fail() && _stringstream_hack) {
245 pos = _ostream->tellp();
261 #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) 262 _iostream->~iostream();
263 (*global_operator_delete)(_iostream);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void seek_eof_write(const char *buffer, std::streamsize num_bytes, bool &fail)
Atomically seeks to the end of the file, and writes a number of bytes to the stream.
void release()
Releases the internal lock.
std::streamsize seek_gpos_eof()
Atomically seeks to EOF and returns the gpos there; that is, returns the file size.
std::streamsize seek_ppos_eof()
Atomically seeks to EOF and returns the ppos there; that is, returns the file size.
void seek_write(std::streamsize pos, const char *buffer, std::streamsize num_bytes, bool &fail)
Atomically seeks to a particular offset from the beginning of the file, and writes a number of bytes ...
void acquire()
Acquires the internal lock.
void seek_read(std::streamsize pos, char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes, bool &eof)
Atomically seeks to a particular offset from the beginning of the file, and reads a number of bytes f...