2013-02-01 11:20:46 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2016-08-05 09:42:15 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
2016-04-26 13:37:22 +08:00
|
|
|
|
2013-02-01 11:20:46 +08:00
|
|
|
http://www.cocos2d-x.org
|
2016-04-26 13:37:22 +08:00
|
|
|
|
2013-02-01 11:20:46 +08:00
|
|
|
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:
|
2016-04-26 13:37:22 +08:00
|
|
|
|
2013-02-01 11:20:46 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2016-04-26 13:37:22 +08:00
|
|
|
|
2013-02-01 11:20:46 +08:00
|
|
|
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__
|
|
|
|
|
2014-09-10 08:53:08 +08:00
|
|
|
#include "platform/CCPlatformConfig.h"
|
2014-01-31 08:51:43 +08:00
|
|
|
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
|
|
|
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "platform/CCFileUtils.h"
|
2014-09-10 08:53:08 +08:00
|
|
|
#include "platform/CCPlatformMacros.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/ccTypes.h"
|
2013-02-01 11:20:46 +08:00
|
|
|
#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
|
|
|
|
|
2016-05-04 09:21:35 +08:00
|
|
|
class ZipFile;
|
|
|
|
|
2013-02-01 11:20:46 +08:00
|
|
|
/**
|
|
|
|
* @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;
|
2013-02-01 11:20:46 +08:00
|
|
|
public:
|
2014-09-09 10:34:48 +08:00
|
|
|
FileUtilsAndroid();
|
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);
|
2015-08-14 21:17:51 +08:00
|
|
|
static AAssetManager* getAssetManager() { return assetmanager; }
|
2016-05-04 09:21:35 +08:00
|
|
|
static ZipFile* getObbFile() { return obbfile; }
|
2013-07-03 09:35:46 +08:00
|
|
|
|
2015-09-22 16:08:23 +08:00
|
|
|
/* override functions */
|
2016-02-08 16:22:17 +08:00
|
|
|
bool init() override;
|
2013-12-18 14:58:17 +08:00
|
|
|
|
2014-10-11 11:20:14 +08:00
|
|
|
virtual std::string getNewFilename(const std::string &filename) const override;
|
2014-09-29 19:25:00 +08:00
|
|
|
|
2016-04-26 13:37:22 +08:00
|
|
|
virtual FileUtils::Status getContents(const std::string& filename, ResizableBuffer* buffer) override;
|
2013-09-07 13:52:23 +08:00
|
|
|
|
2016-02-08 16:22:17 +08:00
|
|
|
virtual std::string getWritablePath() const override;
|
|
|
|
virtual bool isAbsolutePath(const std::string& strPath) const override;
|
2016-04-26 13:37:22 +08:00
|
|
|
|
2013-06-18 17:10:54 +08:00
|
|
|
private:
|
2015-07-10 14:37:42 +08:00
|
|
|
virtual bool isFileExistInternal(const std::string& strFilePath) const override;
|
|
|
|
virtual bool isDirectoryExistInternal(const std::string& dirPath) const override;
|
2013-12-18 14:58:17 +08:00
|
|
|
|
2013-07-03 09:35:46 +08:00
|
|
|
static AAssetManager* assetmanager;
|
2016-05-04 09:21:35 +08:00
|
|
|
static ZipFile* obbfile;
|
2013-02-01 11:20:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// end of platform group
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
2014-01-31 08:51:43 +08:00
|
|
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
|
|
|
|
|
|
|
#endif // __CC_FILEUTILS_ANDROID_H__
|