2009-12-19 19:53:53 +00:00
|
|
|
#ifndef MANGLE_VFS_OGRECLIENT_H
|
|
|
|
#define MANGLE_VFS_OGRECLIENT_H
|
|
|
|
|
|
|
|
#include <OgreArchive.h>
|
|
|
|
#include <assert.h>
|
2010-06-03 18:13:27 +00:00
|
|
|
#include "../vfs.hpp"
|
2009-12-19 19:53:53 +00:00
|
|
|
|
|
|
|
namespace Mangle {
|
|
|
|
namespace VFS {
|
|
|
|
|
|
|
|
/** An OGRE Archive implementation that wraps a Mangle::VFS
|
|
|
|
filesystem.
|
|
|
|
|
2010-08-04 10:20:46 +00:00
|
|
|
This has been built and tested against OGRE 1.6.2, and has been
|
|
|
|
extended for OGRE 1.7. You might have to make your own
|
|
|
|
modifications if you're working with newer (or older) versions.
|
2009-12-19 19:53:53 +00:00
|
|
|
*/
|
2009-12-31 14:37:01 +00:00
|
|
|
class MangleArchive : public Ogre::Archive
|
2009-12-19 19:53:53 +00:00
|
|
|
{
|
2009-12-31 14:37:01 +00:00
|
|
|
VFSPtr vfs;
|
|
|
|
|
2009-12-19 19:53:53 +00:00
|
|
|
public:
|
2009-12-31 14:37:01 +00:00
|
|
|
MangleArchive(VFSPtr _vfs, const std::string &name,
|
|
|
|
const std::string &archType = "Mangle")
|
2010-08-13 14:52:29 +00:00
|
|
|
: Ogre::Archive(name, archType)
|
|
|
|
, vfs(_vfs)
|
|
|
|
{}
|
2009-12-19 19:53:53 +00:00
|
|
|
|
|
|
|
bool isCaseSensitive() const { return vfs->isCaseSensitive; }
|
|
|
|
|
2010-01-01 16:06:41 +00:00
|
|
|
// These do nothing. You have to load / unload the archive in the
|
|
|
|
// constructor/destructor.
|
2009-12-19 19:53:53 +00:00
|
|
|
void load() {}
|
|
|
|
void unload() {}
|
|
|
|
|
|
|
|
bool exists(const Ogre::String& filename)
|
|
|
|
{ return vfs->isFile(filename); }
|
|
|
|
|
|
|
|
time_t getModifiedTime(const Ogre::String& filename)
|
2010-01-01 16:06:41 +00:00
|
|
|
{ return vfs->stat(filename)->time; }
|
2009-12-19 19:53:53 +00:00
|
|
|
|
2010-07-03 16:46:21 +00:00
|
|
|
// With both these we support both OGRE 1.6 and 1.7
|
2009-12-19 19:53:53 +00:00
|
|
|
Ogre::DataStreamPtr open(const Ogre::String& filename) const;
|
2010-07-03 16:46:21 +00:00
|
|
|
Ogre::DataStreamPtr open(const Ogre::String& filename, bool readOnly) const
|
|
|
|
{ return open(filename); }
|
2009-12-19 19:53:53 +00:00
|
|
|
|
|
|
|
Ogre::StringVectorPtr list(bool recursive = true, bool dirs = false);
|
|
|
|
Ogre::FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false);
|
|
|
|
|
|
|
|
// Find functions will only work if vfs->hasFind is set.
|
|
|
|
Ogre::StringVectorPtr find(const Ogre::String& pattern, bool recursive = true,
|
|
|
|
bool dirs = false);
|
2011-04-03 11:06:42 +00:00
|
|
|
Ogre::FileInfoListPtr findFileInfo(const Ogre::String& pattern,
|
2009-12-19 19:53:53 +00:00
|
|
|
bool recursive = true,
|
|
|
|
bool dirs = false);
|
|
|
|
};
|
|
|
|
|
|
|
|
}} // namespaces
|
|
|
|
#endif
|