mirror of https://github.com/OpenMW/openmw.git
Merge commit '008b4c'
commit
165952f916
@ -0,0 +1,39 @@
|
||||
#include "audiere_file.h"
|
||||
|
||||
using namespace audiere;
|
||||
using namespace Mangle::Stream;
|
||||
|
||||
bool AudiereFile::seek(int pos, SeekMode mode)
|
||||
{
|
||||
assert(inp->isSeekable);
|
||||
assert(inp->hasPosition);
|
||||
|
||||
if(mode == BEGIN)
|
||||
{
|
||||
// Absolute position
|
||||
inp->seek(pos);
|
||||
return inp->tell() == pos;
|
||||
}
|
||||
if(mode == CURRENT)
|
||||
{
|
||||
// Current position
|
||||
int cpos = inp->tell();
|
||||
|
||||
// Seek to a elative position
|
||||
inp->seek(cpos + pos);
|
||||
return inp->tell() == (pos+cpos);
|
||||
}
|
||||
if(mode == END)
|
||||
{
|
||||
// Seeking from the end. This requires that we're able to get
|
||||
// the entire size of the file. The pos also has to be
|
||||
// non-positive.
|
||||
assert(inp->hasSize);
|
||||
assert(pos <= 0);
|
||||
|
||||
size_t epos = inp->size();
|
||||
inp->seek(epos + pos);
|
||||
return inp->tell() == (epos+pos);
|
||||
}
|
||||
assert(0 && "invalid seek mode");
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
#ifndef MANGLE_STREAM_AUDIERECLIENT_H
|
||||
#define MANGLE_STREAM_AUDIERECLIENT_H
|
||||
|
||||
#include <audiere.h>
|
||||
#include <assert.h>
|
||||
#include "iwrapper.h"
|
||||
|
||||
namespace Mangle {
|
||||
namespace Stream {
|
||||
|
||||
/** @brief An Audiere::File that wraps a Mangle::Stream input.
|
||||
|
||||
This lets Audiere read sound files from any generic archive or
|
||||
file manager that supports Mangle streams.
|
||||
*/
|
||||
class AudiereFile : public audiere::File, _IWrapper
|
||||
{
|
||||
public:
|
||||
AudiereFile(InputStream *inp, bool autoDel=false)
|
||||
: _IWrapper(inp, autoDel) {}
|
||||
|
||||
/// Read 'count' bytes, return bytes successfully read
|
||||
int read(void *buf, int count)
|
||||
{ return inp->read(buf,count); }
|
||||
|
||||
/// Seek, relative to specified seek mode. Returns true if successful.
|
||||
bool seek(int pos, audiere::SeekMode mode);
|
||||
|
||||
/// Get current position
|
||||
int tell()
|
||||
{ assert(inp->hasPosition); return inp->tell(); }
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
#endif
|
@ -0,0 +1,35 @@
|
||||
#ifndef MANGLE_STREAM_OGRESERVER_H
|
||||
#define MANGLE_STREAM_OGRESERVER_H
|
||||
|
||||
#include <OgreDataStream.h>
|
||||
|
||||
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
|
@ -0,0 +1,62 @@
|
||||
#ifndef MANGLE_VFS_OGRECLIENT_H
|
||||
#define MANGLE_VFS_OGRECLIENT_H
|
||||
|
||||
#include <OgreArchive.h>
|
||||
|
||||
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
|
Loading…
Reference in New Issue