forked from metin2/client
74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <windows.h>
|
|
#include <unordered_map>
|
|
#include "../eterBase/Singleton.h"
|
|
#include "../eterBase/Stl.h"
|
|
|
|
#include "FileProvider.h"
|
|
#include "EterPack.h"
|
|
|
|
class CEterPackManager : public CSingleton<CEterPackManager>
|
|
{
|
|
public:
|
|
struct SCache
|
|
{
|
|
BYTE* m_abBufData;
|
|
DWORD m_dwBufSize;
|
|
};
|
|
public:
|
|
enum ESearchModes
|
|
{
|
|
SEARCH_FILE_FIRST,
|
|
SEARCH_PACK_FIRST
|
|
};
|
|
|
|
typedef std::list<std::shared_ptr<FileProvider>> TEterPackList;
|
|
typedef std::unordered_map<std::string, std::shared_ptr<FileProvider>, stringhash> TEterPackMap;
|
|
|
|
public:
|
|
CEterPackManager();
|
|
virtual ~CEterPackManager();
|
|
|
|
void SetCacheMode();
|
|
void SetRelativePathMode();
|
|
|
|
void LoadStaticCache(const char* c_szFileName);
|
|
|
|
void SetSearchMode(bool bPackFirst);
|
|
int GetSearchMode();
|
|
|
|
bool Get(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
|
|
|
|
bool GetFromPack(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
|
|
|
|
bool GetFromFile(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
|
|
bool isExist(const char * c_szFileName);
|
|
bool isExistInPack(const char * c_szFileName);
|
|
|
|
bool RegisterPack(const char * c_szName, const char * c_szDirectory, const BYTE* c_pbIV = NULL);
|
|
std::string ConvertFileName(std::string fileName);
|
|
|
|
protected:
|
|
bool CompareName(const char * c_szDirectoryName, DWORD iLength, const char * c_szFileName);
|
|
|
|
std::shared_ptr<FileProvider> FindPack(const char* c_szPathName);
|
|
|
|
SCache* __FindCache(DWORD dwFileNameHash);
|
|
void __ClearCacheMap();
|
|
|
|
protected:
|
|
bool m_bTryRelativePath;
|
|
bool m_isCacheMode;
|
|
int m_iSearchMode;
|
|
|
|
std::unordered_map<DWORD, std::shared_ptr<FileProvider>> m_FileDict;
|
|
TEterPackMap m_PackMap;
|
|
|
|
std::unordered_map<DWORD, SCache> m_kMap_dwNameKey_kCache;
|
|
|
|
std::vector<std::shared_ptr<std::vector<char>>> keepDataReferencedArray;
|
|
|
|
CRITICAL_SECTION m_csFinder;
|
|
};
|