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