2009-12-26 11:13:31 +00:00
|
|
|
#ifndef MANGLE_VFS_OGRESERVER_H
|
|
|
|
#define MANGLE_VFS_OGRESERVER_H
|
2009-12-22 15:58:19 +00:00
|
|
|
|
2010-06-03 18:13:27 +00:00
|
|
|
#include "../vfs.hpp"
|
2009-12-26 11:13:31 +00:00
|
|
|
#include <OgreResourceGroupManager.h>
|
2009-12-22 15:58:19 +00:00
|
|
|
|
|
|
|
namespace Mangle {
|
|
|
|
namespace VFS {
|
|
|
|
|
|
|
|
/** @brief An interface into the OGRE VFS system.
|
|
|
|
|
2009-12-26 11:13:31 +00:00
|
|
|
This class does NOT wrap a single Ogre::Archive, but rather an
|
|
|
|
entire resource group in Ogre. You can use this class to tap into
|
|
|
|
all paths, Zip files, custom archives on so on that have been
|
|
|
|
inserted into Ogre as resource locations.
|
2009-12-22 15:58:19 +00:00
|
|
|
|
|
|
|
This has been built and tested against OGRE 1.6.2. You might have
|
|
|
|
to make your own modifications if you're working with newer (or
|
|
|
|
older) versions.
|
|
|
|
*/
|
|
|
|
class OgreVFS : public VFS
|
|
|
|
{
|
2009-12-26 11:13:31 +00:00
|
|
|
std::string group;
|
|
|
|
Ogre::ResourceGroupManager *gm;
|
|
|
|
|
2009-12-22 15:58:19 +00:00
|
|
|
public:
|
2009-12-26 11:13:31 +00:00
|
|
|
/** @brief Constructor
|
|
|
|
|
|
|
|
OGRE must be initialized (ie. you must have created an
|
|
|
|
Ogre::Root object somewhere) before calling this.
|
|
|
|
|
|
|
|
@param group Optional resource group name. If none is given,
|
|
|
|
OGRE's default (or 'World') resource group is used.
|
|
|
|
*/
|
|
|
|
OgreVFS(const std::string &_group = "");
|
2009-12-22 15:58:19 +00:00
|
|
|
|
|
|
|
/// Open a new data stream. Deleting the object should be enough to
|
|
|
|
/// close it.
|
2009-12-31 14:37:01 +00:00
|
|
|
virtual Stream::StreamPtr open(const std::string &name);
|
2009-12-22 15:58:19 +00:00
|
|
|
|
|
|
|
/// Check for the existence of a file
|
2009-12-26 11:13:31 +00:00
|
|
|
virtual bool isFile(const std::string &name) const
|
|
|
|
{ return gm->resourceExists(group, name); }
|
2009-12-22 15:58:19 +00:00
|
|
|
|
2009-12-26 11:13:31 +00:00
|
|
|
/// This doesn't work, always returns false.
|
|
|
|
virtual bool isDir(const std::string &name) const
|
|
|
|
{ return false; }
|
2009-12-22 15:58:19 +00:00
|
|
|
|
2009-12-26 11:13:31 +00:00
|
|
|
/// This doesn't work.
|
2009-12-31 14:37:01 +00:00
|
|
|
virtual FileInfoPtr stat(const std::string &name) const
|
|
|
|
{ return FileInfoPtr(); }
|
2009-12-22 15:58:19 +00:00
|
|
|
|
|
|
|
/// List all entries in a given directory. A blank dir should be
|
|
|
|
/// interpreted as a the root/current directory of the archive. If
|
2009-12-26 11:13:31 +00:00
|
|
|
/// dirs is true, list directories instead of files. OGRE note: The
|
|
|
|
/// ogre resource systemd does not support recursive listing of
|
|
|
|
/// files. We might make a separate filter for this later.
|
2009-12-31 14:37:01 +00:00
|
|
|
virtual FileInfoListPtr list(const std::string& dir = "",
|
|
|
|
bool recurse=true,
|
|
|
|
bool dirs=false) const;
|
2009-12-22 15:58:19 +00:00
|
|
|
|
|
|
|
/// Find files after a given pattern. Wildcards (*) are
|
2009-12-26 11:13:31 +00:00
|
|
|
/// supported.
|
2009-12-31 14:37:01 +00:00
|
|
|
virtual FileInfoListPtr find(const std::string& pattern,
|
|
|
|
bool recursive=true,
|
|
|
|
bool dirs=false) const;
|
2009-12-22 15:58:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}} // namespaces
|
|
|
|
#endif
|