CCFileUtils-apple.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2011 Zynga Inc.
  4. Copyright (c) 2013-2017 Chukong Technologies Inc.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __CC_FILEUTILS_APPLE_H__
  23. #define __CC_FILEUTILS_APPLE_H__
  24. #include <memory>
  25. #include <string>
  26. #include <vector>
  27. #include "platform/CCFileUtils.h"
  28. #include "platform/CCPlatformMacros.h"
  29. #include "base/ccTypes.h"
  30. NS_CC_BEGIN
  31. /**
  32. * @addtogroup platform
  33. * @{
  34. */
  35. //! @brief Helper class to handle file operations
  36. class CC_DLL FileUtilsApple : public FileUtils
  37. {
  38. public:
  39. FileUtilsApple();
  40. virtual ~FileUtilsApple();
  41. /* override functions */
  42. virtual std::string getWritablePath() const override;
  43. virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename) const override;
  44. virtual ValueMap getValueMapFromFile(const std::string& filename) override;
  45. virtual ValueMap getValueMapFromData(const char* filedata, int filesize)override;
  46. virtual bool writeToFile(const ValueMap& dict, const std::string& fullPath) override;
  47. virtual ValueVector getValueVectorFromFile(const std::string& filename) override;
  48. #if CC_FILEUTILS_APPLE_ENABLE_OBJC
  49. void setBundle(NSBundle* bundle);
  50. #endif
  51. virtual bool createDirectory(const std::string& path) override;
  52. private:
  53. virtual bool isFileExistInternal(const std::string& filePath) const override;
  54. virtual bool removeDirectory(const std::string& dirPath) override;
  55. virtual void valueMapCompact(ValueMap& valueMap) override;
  56. virtual void valueVectorCompact(ValueVector& valueVector) override;
  57. struct IMPL;
  58. std::unique_ptr<IMPL> pimpl_;
  59. };
  60. // end of platform group
  61. /// @}
  62. NS_CC_END
  63. #endif // __CC_FILEUTILS_APPLE_H__