// // BigFile.h // HelloLua // // Created by mac on 14-11-27. // // #ifndef __HelloLua__BigFile__ #define __HelloLua__BigFile__ #define HUNXIAO true #include #include #include #include #include #include "cocos2d.h" using namespace std; #include "json11.hpp" using namespace json11; class BigFile :cocos2d::Ref { public: virtual ~BigFile(){}; void targetFileNameFromDirAndFile(string& directory, string& filename); bool needDecode(string filepath); static bool inited; static BigFile* getInstance(); void rc4_crypt(unsigned char *Data, ssize_t Len); void clearDataCache(); void saveDataToCache(string path, unsigned char* buffer, ssize_t size); const unsigned char* getDataFromCache(string path, ssize_t *size); protected: bool b_IsHunXiao; string _assertDir; string _confFilePath; string _packname; bool b_configInited; Json _confFileRoot; Json _pathCfgRoot; Json _decCfgRoot; static BigFile* s_sharedBigFile; string _lastMusicFile; bool _useCache; map> _cachedDataDic; // 缓存锁,保证线程安全 std::mutex _cachedDataDicMutex; BigFile(bool useCache = true); void setupPackName(); void setupConfFileRoot(); private: // 获取package name std::string _getAndroidPackageName(); // 数字的app id std::string _getIOSAppId(); }; #endif /* defined(__HelloLua__BigFile__) */