2013-02-01 11:20:46 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
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 __CC_FILEUTILS_ANDROID_H__
|
|
|
|
#define __CC_FILEUTILS_ANDROID_H__
|
|
|
|
|
|
|
|
#include "platform/CCFileUtils.h"
|
2013-10-14 14:01:00 +08:00
|
|
|
#include "CCPlatformMacros.h"
|
2013-02-01 11:20:46 +08:00
|
|
|
#include "ccTypes.h"
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2013-03-08 05:56:42 +08:00
|
|
|
#include "jni.h"
|
|
|
|
#include "android/asset_manager.h"
|
|
|
|
|
2013-02-01 11:20:46 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup platform
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! @brief Helper class to handle file operations
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL FileUtilsAndroid : public FileUtils
|
2013-02-01 11:20:46 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
friend class FileUtils;
|
|
|
|
FileUtilsAndroid();
|
2013-02-01 11:20:46 +08:00
|
|
|
public:
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ~FileUtilsAndroid();
|
2013-02-01 22:19:58 +08:00
|
|
|
|
2013-07-03 09:35:46 +08:00
|
|
|
static void setassetmanager(AAssetManager* a);
|
|
|
|
|
2013-02-01 11:20:46 +08:00
|
|
|
/* override funtions */
|
|
|
|
bool init();
|
2013-07-26 06:53:24 +08:00
|
|
|
virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize);
|
2013-09-07 13:52:23 +08:00
|
|
|
|
|
|
|
virtual std::string getWritablePath() const;
|
|
|
|
virtual bool isFileExist(const std::string& strFilePath) const;
|
|
|
|
virtual bool isAbsolutePath(const std::string& strPath) const;
|
2013-06-18 17:10:54 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** This function is android specific. It is used for TextureCache::addImageAsync().
|
2013-06-18 17:10:54 +08:00
|
|
|
Don't use it in your codes.
|
|
|
|
*/
|
2013-07-26 06:53:24 +08:00
|
|
|
unsigned char* getFileDataForAsync(const char* filename, const char* pszMode, unsigned long * pSize);
|
2013-06-18 17:10:54 +08:00
|
|
|
|
|
|
|
private:
|
2013-07-26 06:53:24 +08:00
|
|
|
unsigned char* doGetFileData(const char* filename, const char* pszMode, unsigned long * pSize, bool forAsync);
|
2013-07-03 09:35:46 +08:00
|
|
|
static AAssetManager* assetmanager;
|
2013-02-01 11:20:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// end of platform group
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif // __CC_FILEUTILS_ANDROID_H__
|