OgreAPKFileSystemArchive.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __APKFileSystemArchive_H__
#define __APKFileSystemArchive_H__
#include <OgreArchive.h>
#include <OgreArchiveFactory.h>
#include <android/asset_manager.h>
namespace Ogre{
class APKFileSystemArchive : public Archive
{
private:
AAssetManager* mAssetMgr;
String mPathPreFix;
public:
APKFileSystemArchive(const String& name, const String& archType, AAssetManager* assetMgr);
~APKFileSystemArchive();
bool isCaseSensitive(void) const;
void load();
void unload();
DataStreamPtr open(const String& filename, bool readOnly = true) const;
DataStreamPtr create(const String& filename) const;
void remove(const String& filename) const;
StringVectorPtr list(bool recursive = true, bool dirs = false);
FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false);
StringVectorPtr find(const String& pattern, bool recursive = true, bool dirs = false);
FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true, bool dirs = false) const;
bool exists(const String& filename);
time_t getModifiedTime(const String& filename);
};
class APKFileSystemArchiveFactory : public ArchiveFactory
{
public:
APKFileSystemArchiveFactory(AAssetManager* assetMgr) : mAssetMgr(assetMgr) {}
virtual ~APKFileSystemArchiveFactory() {}
const String& getType(void) const;
Archive *createInstance( const String& name, bool readOnly )
{
return OGRE_NEW APKFileSystemArchive(name, getType(), mAssetMgr);
}
void destroyInstance( Archive* arch) { OGRE_DELETE arch; }
private:
AAssetManager* mAssetMgr;
};
}
#endif
Ogre::APKFileSystemArchive::unload
void unload()
Unloads the archive.
Ogre::APKFileSystemArchive::mAssetMgr
AAssetManager * mAssetMgr
Definition: OgreAPKFileSystemArchive.h:40
Ogre::APKFileSystemArchiveFactory::APKFileSystemArchiveFactory
APKFileSystemArchiveFactory(AAssetManager *assetMgr)
Definition: OgreAPKFileSystemArchive.h:86
Ogre::APKFileSystemArchive::open
DataStreamPtr open(const String &filename, bool readOnly=true) const
Open a stream on a given file.
Ogre::APKFileSystemArchive
Definition: OgreAPKFileSystemArchive.h:37
Ogre::APKFileSystemArchive::isCaseSensitive
bool isCaseSensitive(void) const
Returns whether this archive is case sensitive in the way it matches files.
Ogre::APKFileSystemArchiveFactory::destroyInstance
void destroyInstance(Archive *arch)
Destroys an object which was created by this factory.
Definition: OgreAPKFileSystemArchive.h:96
OGRE_DELETE
#define OGRE_DELETE
Definition: OgreMemoryAllocatorConfig.h:474
Ogre::APKFileSystemArchive::find
StringVectorPtr find(const String &pattern, bool recursive=true, bool dirs=false)
Find all file or directory names matching a given pattern in this archive.
Ogre::APKFileSystemArchive::load
void load()
Loads the archive.
Ogre::APKFileSystemArchive::listFileInfo
FileInfoListPtr listFileInfo(bool recursive=true, bool dirs=false)
List all files in the archive with accompanying information.
Ogre::APKFileSystemArchive::mPathPreFix
String mPathPreFix
Definition: OgreAPKFileSystemArchive.h:41
OGRE_NEW
#define OGRE_NEW
Definition: OgreMemoryAllocatorConfig.h:473
Ogre::APKFileSystemArchive::getModifiedTime
time_t getModifiedTime(const String &filename)
Retrieve the modification time of a given file.
Ogre::APKFileSystemArchiveFactory
Definition: OgreAPKFileSystemArchive.h:83
OgreArchiveFactory.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::APKFileSystemArchive::findFileInfo
FileInfoListPtr findFileInfo(const String &pattern, bool recursive=true, bool dirs=false) const
Find all files or directories matching a given pattern in this archive and get some detailed informat...
Ogre::Archive::getType
const String & getType(void) const
Return the type code of this Archive.
Definition: OgreArchive.h:233
Ogre::APKFileSystemArchiveFactory::createInstance
Archive * createInstance(const String &name, bool readOnly)
Creates a new object.
Definition: OgreAPKFileSystemArchive.h:91
Ogre::APKFileSystemArchive::exists
bool exists(const String &filename)
Find out if the named file exists (note: fully qualified filename required)
Ogre::ArchiveFactory
Abstract factory class, archive codec plugins can register concrete subclasses of this...
Definition: OgreArchiveFactory.h:59
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::APKFileSystemArchive::APKFileSystemArchive
APKFileSystemArchive(const String &name, const String &archType, AAssetManager *assetMgr)
Ogre::APKFileSystemArchive::create
DataStreamPtr create(const String &filename) const
Create a new file (or overwrite one already there).
Ogre::SharedPtr< DataStream >
OgreArchive.h
Ogre::APKFileSystemArchiveFactory::mAssetMgr
AAssetManager * mAssetMgr
Definition: OgreAPKFileSystemArchive.h:98
Ogre::Archive
Archive-handling class.
Definition: OgreArchive.h:88
Ogre::APKFileSystemArchive::list
StringVectorPtr list(bool recursive=true, bool dirs=false)
List all file names in the archive.
Ogre::APKFileSystemArchive::~APKFileSystemArchive
~APKFileSystemArchive()
Ogre::APKFileSystemArchiveFactory::~APKFileSystemArchiveFactory
virtual ~APKFileSystemArchiveFactory()
Definition: OgreAPKFileSystemArchive.h:87

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.