12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // BigFile.h
- // HelloLua
- //
- // Created by mac on 14-11-27.
- //
- //
- #ifndef __HelloLua__BigFile__
- #define __HelloLua__BigFile__
- #define HUNXIAO true
- #include <iostream>
- #include <map>
- #include <string>
- #include <mutex>
- #include <tuple>
- #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<string, tuple<unsigned char*,unsigned long>> _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__) */
|