15 #include "physxFileStream.h"
19 #include "virtualFileSystem.h"
26 PhysxFileStream::PhysxFileStream(
const Filename &fn,
bool load) : _fp(NULL), _vf(NULL), _in(NULL)
30 _in = _vf->open_read_file(
true);
33 _fp = fopen(fn.c_str(),
"wb");
42 PhysxFileStream::~PhysxFileStream()
45 if (_vf) _vf->close_read_file(_in);
53 NxU8 PhysxFileStream::readByte()
const
56 _in->read((
char *)&b,
sizeof(NxU8));
57 NX_ASSERT(!(_in->bad()));
66 NxU16 PhysxFileStream::readWord()
const
69 _in->read((
char *)&w,
sizeof(NxU16));
70 NX_ASSERT(!(_in->bad()));
79 NxU32 PhysxFileStream::readDword()
const
82 _in->read((
char *)&d,
sizeof(NxU32));
83 NX_ASSERT(!(_in->bad()));
92 float PhysxFileStream::readFloat()
const
95 _in->read((
char *)&f,
sizeof(NxReal));
96 NX_ASSERT(!(_in->bad()));
105 double PhysxFileStream::readDouble()
const
108 _in->read((
char *)&f,
sizeof(NxF64));
109 NX_ASSERT(!(_in->bad()));
118 void PhysxFileStream::readBuffer(
void *buffer, NxU32 size)
const
120 _in->read((
char *)buffer, size);
121 NX_ASSERT(!(_in->bad()));
129 NxStream &PhysxFileStream::storeByte(NxU8 b)
131 size_t w = fwrite(&b,
sizeof(NxU8), 1, _fp);
141 NxStream &PhysxFileStream::storeWord(NxU16 w)
143 size_t ww = fwrite(&w,
sizeof(NxU16), 1, _fp);
153 NxStream &PhysxFileStream::storeDword(NxU32 d)
155 size_t w = fwrite(&d,
sizeof(NxU32), 1, _fp);
165 NxStream &PhysxFileStream::storeFloat(NxReal f)
167 size_t w = fwrite(&f,
sizeof(NxReal), 1, _fp);
177 NxStream &PhysxFileStream::storeDouble(NxF64 f)
179 size_t w = fwrite(&f,
sizeof(NxF64), 1, _fp);
189 NxStream &PhysxFileStream::storeBuffer(
const void *buffer, NxU32 size)
191 size_t w = fwrite(buffer, size, 1, _fp);
The name of a file, such as a texture file or an Egg file.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
PointerTo< VirtualFile > get_file(const Filename &filename, bool status_only=false) const
Looks up the file by the indicated name in the file system.