23 if (_vfs ==
nullptr) {
31 Rocket::Core::FileHandle RocketFileInterface::
32 Open(
const Rocket::Core::String& path) {
33 rocket_cat.debug() <<
"Opening " << path.CString() <<
"\n";
38 if (file ==
nullptr) {
41 rocket_cat.error() <<
"Could not resolve " << fn
42 <<
" along the model-path (currently: " << get_model_path() <<
")\n";
43 return (Rocket::Core::FileHandle)
nullptr;
47 if (file ==
nullptr) {
48 rocket_cat.error() <<
"Failed to get " << fn <<
", found on model-path\n";
49 return (Rocket::Core::FileHandle)
nullptr;
53 std::istream *str = file->open_read_file(
true);
55 rocket_cat.error() <<
"Failed to open " << fn <<
" for reading\n";
56 return (Rocket::Core::FileHandle)
nullptr;
59 VirtualFileHandle *handle =
new VirtualFileHandle;
61 handle->_stream = str;
64 return (Rocket::Core::FileHandle) handle;
70 void RocketFileInterface::
71 Close(Rocket::Core::FileHandle file) {
72 VirtualFileHandle *handle = (VirtualFileHandle*) file;
73 if (handle ==
nullptr) {
84 size_t RocketFileInterface::
85 Read(
void* buffer,
size_t size, Rocket::Core::FileHandle file) {
86 VirtualFileHandle *handle = (VirtualFileHandle*) file;
87 if (handle ==
nullptr) {
91 handle->_stream->read((
char*) buffer, size);
92 return handle->_stream->gcount();
98 bool RocketFileInterface::
99 Seek(Rocket::Core::FileHandle file,
long offset,
int origin) {
100 VirtualFileHandle *handle = (VirtualFileHandle*) file;
101 if (handle ==
nullptr) {
107 handle->_stream->seekg(offset, std::ios::beg);
110 handle->_stream->seekg(offset, std::ios::cur);
113 handle->_stream->seekg(offset, std::ios::end);
116 return !handle->_stream->fail();
122 size_t RocketFileInterface::
123 Tell(Rocket::Core::FileHandle file) {
124 VirtualFileHandle *handle = (VirtualFileHandle*) file;
125 if (handle ==
nullptr) {
129 return handle->_stream->tellg();
135 size_t RocketFileInterface::
136 Length(Rocket::Core::FileHandle file) {
137 VirtualFileHandle *handle = (VirtualFileHandle*) file;
138 if (handle ==
nullptr) {
142 return handle->_file->get_file_size(handle->_stream);