CCFileUtils-android.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2017 Chukong Technologies Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __CC_FILEUTILS_ANDROID_H__
  22. #define __CC_FILEUTILS_ANDROID_H__
  23. #include "platform/CCPlatformConfig.h"
  24. #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
  25. #include "platform/CCFileUtils.h"
  26. #include "platform/CCPlatformMacros.h"
  27. #include "base/ccTypes.h"
  28. #include <string>
  29. #include <vector>
  30. #include "jni.h"
  31. #include "android/asset_manager.h"
  32. NS_CC_BEGIN
  33. class ZipFile;
  34. /**
  35. * @addtogroup platform
  36. * @{
  37. */
  38. //! @brief Helper class to handle file operations
  39. class CC_DLL FileUtilsAndroid : public FileUtils
  40. {
  41. friend class FileUtils;
  42. public:
  43. FileUtilsAndroid();
  44. /**
  45. * @js NA
  46. * @lua NA
  47. */
  48. virtual ~FileUtilsAndroid();
  49. static void setassetmanager(AAssetManager* a);
  50. static AAssetManager* getAssetManager() { return assetmanager; }
  51. static ZipFile* getObbFile() { return obbfile; }
  52. /* override functions */
  53. bool init() override;
  54. virtual std::string getNewFilename(const std::string &filename) const override;
  55. virtual FileUtils::Status getContents(const std::string& filename, ResizableBuffer* buffer) override;
  56. virtual std::string getWritablePath() const override;
  57. virtual bool isAbsolutePath(const std::string& strPath) const override;
  58. private:
  59. virtual bool isFileExistInternal(const std::string& strFilePath) const override;
  60. virtual bool isDirectoryExistInternal(const std::string& dirPath) const override;
  61. static AAssetManager* assetmanager;
  62. static ZipFile* obbfile;
  63. };
  64. // end of platform group
  65. /// @}
  66. NS_CC_END
  67. #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
  68. #endif // __CC_FILEUTILS_ANDROID_H__