OgreAPKZipArchive.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 __APKZipArchive_H__
#define __APKZipArchive_H__
#include <OgreZip.h>
#include <OgreLogManager.h>
#include <android/asset_manager.h>
namespace Ogre{
class APKZipArchiveFactory : public EmbeddedZipArchiveFactory
{
protected:
AAssetManager* mAssetMgr;
public:
APKZipArchiveFactory(AAssetManager* assetMgr) : mAssetMgr(assetMgr) {}
virtual ~APKZipArchiveFactory() {}
const String& getType(void) const;
Archive *createInstance( const String& name, bool readOnly )
{
String apkName = name;
if (apkName.size() > 0 && apkName[0] == '/')
apkName.erase(apkName.begin());
AAsset* asset = AAssetManager_open(mAssetMgr, apkName.c_str(), AASSET_MODE_BUFFER);
if(asset)
{
EmbeddedZipArchiveFactory::addEmbbeddedFile(apkName, (const Ogre::uint8*)AAsset_getBuffer(asset), AAsset_getLength(asset), 0);
}
ZipArchive * resZipArchive = OGRE_NEW ZipArchive(apkName, "APKZip", mPluginIo);
return resZipArchive;
}
};
}
#endif
Ogre::EmbeddedZipArchiveFactory::addEmbbeddedFile
static void addEmbbeddedFile(const String &name, const uint8 *fileData, size_t fileSize, DecryptEmbeddedZipFileFunc decryptFunc)
Add an embedded file to the embedded file list.
Ogre::APKZipArchiveFactory::getType
const String & getType(void) const
Returns the factory type.
OgreLogManager.h
Ogre::EmbeddedZipArchiveFactory
Specialisation of ZipArchiveFactory for embedded Zip files.
Definition: OgreZip.h:133
OGRE_NEW
#define OGRE_NEW
Definition: OgreMemoryAllocatorConfig.h:473
Ogre::APKZipArchiveFactory::createInstance
Archive * createInstance(const String &name, bool readOnly)
Creates a new object.
Definition: OgreAPKZipArchive.h:50
Ogre::APKZipArchiveFactory
Definition: OgreAPKZipArchive.h:38
OgreZip.h
Ogre::APKZipArchiveFactory::mAssetMgr
AAssetManager * mAssetMgr
Definition: OgreAPKZipArchive.h:41
Ogre::APKZipArchiveFactory::APKZipArchiveFactory
APKZipArchiveFactory(AAssetManager *assetMgr)
Definition: OgreAPKZipArchive.h:43
Ogre::uint8
unsigned char uint8
Definition: OgrePlatform.h:361
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::EmbeddedZipArchiveFactory::mPluginIo
static zzip_plugin_io_handlers * mPluginIo
A static pointer to file io alternative implementation for the embedded files.
Definition: OgreZip.h:137
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Archive
Archive-handling class.
Definition: OgreArchive.h:88
Ogre::ZipArchive
Specialisation of the Archive class to allow reading of files from a zip format source archive...
Definition: OgreZip.h:59
Ogre::APKZipArchiveFactory::~APKZipArchiveFactory
virtual ~APKZipArchiveFactory()
Definition: OgreAPKZipArchive.h:44

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