diff --git a/stream/imp_server/ogre_datastream.h b/stream/imp_server/ogre_datastream.h new file mode 100644 index 000000000..ef922fa7f --- /dev/null +++ b/stream/imp_server/ogre_datastream.h @@ -0,0 +1,35 @@ +#ifndef MANGLE_STREAM_OGRESERVER_H +#define MANGLE_STREAM_OGRESERVER_H + +#include + +namespace Mangle { +namespace Stream { + +/** A Stream wrapping an OGRE DataStream. + + 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 OgreStream : public InputStream +{ + Ogre::DataStreamPtr inp; + + public: + OgreStream(Ogre::DataStreamPtr _inp) : inp(_inp) + { + isSeekable = true; + hasPosition = true; + hasSize = true; + } + + size_t read(void *buf, size_t count) { return inp->read(buf,count); } + void seek(size_t pos) { inp->seek(pos); } + size_t tell() const { return inp->tell(); } + size_t size() const { return inp->size(); } + bool eof() const { return inp->eof(); } +}; + +}} // namespaces +#endif diff --git a/vfs/imp_client/ogre_archive.h b/vfs/imp_client/ogre_archive.h index f72398a2d..70e6045c4 100644 --- a/vfs/imp_client/ogre_archive.h +++ b/vfs/imp_client/ogre_archive.h @@ -18,7 +18,6 @@ namespace VFS { class MangleArchive : public Ogre::Archive, _Wrapper { public: - /// Constructor without name MangleArchive(VFS *vfs, const std::string &name, const std::string &archType = "Mangle", bool autoDel=false) diff --git a/vfs/imp_server/ogre_vfs.h b/vfs/imp_server/ogre_vfs.h new file mode 100644 index 000000000..98cf5da79 --- /dev/null +++ b/vfs/imp_server/ogre_vfs.h @@ -0,0 +1,62 @@ +#ifndef MANGLE_VFS_OGRECLIENT_H +#define MANGLE_VFS_OGRECLIENT_H + +#include + +namespace Mangle { +namespace VFS { + +/** @brief An interface into the OGRE VFS system. + + This class does not wrap a single Ogre::Archive, but rather the + entire resource set available to 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. + + This class is currently a work in progres, it will not compile as + it stands. + + 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 +{ + public: + OgreVFS() + { + hasFind = true; + isCaseSensitive = true; + } + + /// Open a new data stream. Deleting the object should be enough to + /// close it. + virtual Stream::InputStream *open(const std::string &name); + + /// Check for the existence of a file + virtual bool isFile(const std::string &name) const; + + /// Check for the existence of a directory + virtual bool isDir(const std::string &name) const; + + /// Get info about a single file + virtual FileInfo stat(const std::string &name) const; + + /// List all entries in a given directory. A blank dir should be + /// interpreted as a the root/current directory of the archive. If + /// dirs is true, list directories instead of files. + virtual FileInfoList list(const std::string& dir = "", + bool recurse=true, + bool dirs=false) const; + + /// Find files after a given pattern. Wildcards (*) are + /// supported. Only valid if 'hasFind' is true. Don't implement your + /// own pattern matching here if the backend doesn't support it + /// natively; use a filter instead (not implemented yet.) + virtual FileInfoList find(const std::string& pattern, + bool recursive=true, + bool dirs=false) const; +}; + +}} // namespaces +#endif