Panda3D
rocketFileInterface.h
1 // Filename: rocketFileInterface.h
2 // Created by: rdb (03Nov11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ROCKET_FILE_INTERFACE_H
16 #define ROCKET_FILE_INTERFACE_H
17 
18 #include "config_rocket.h"
19 #include "virtualFile.h"
20 #include <Rocket/Core/FileInterface.h>
21 
22 class VirtualFileSystem;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : RocketFileInterface
26 // Description : Implementation of FileInterface to allow libRocket
27 // to read files from the virtual file system.
28 ////////////////////////////////////////////////////////////////////
29 class RocketFileInterface : public Rocket::Core::FileInterface {
30 public:
32  virtual ~RocketFileInterface() {};
33 
34  Rocket::Core::FileHandle Open(const Rocket::Core::String& path);
35  void Close(Rocket::Core::FileHandle file);
36 
37  size_t Read(void* buffer, size_t size, Rocket::Core::FileHandle file);
38  bool Seek(Rocket::Core::FileHandle file, long offset, int origin);
39  size_t Tell(Rocket::Core::FileHandle file);
40 
41  size_t Length(Rocket::Core::FileHandle file);
42 
43 protected:
44  struct VirtualFileHandle {
45  PT(VirtualFile) _file;
46  istream *_stream;
47  };
48 
49  VirtualFileSystem* _vfs;
50 };
51 
52 #endif
RocketFileInterface(VirtualFileSystem *vfs=NULL)
Constructs a RocketFileInterface for the given VFS, or the default if NULL is given.
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS&#39;s file system.
The abstract base class for a file or directory within the VirtualFileSystem.
Definition: virtualFile.h:37
Definition: seek.h:24
Implementation of FileInterface to allow libRocket to read files from the virtual file system...