//-------------------------------------------------- /// 构造函数 //-------------------------------------------------- public CHttpFileCacher(int max, string folderName, string fileExtension) { m_maxCnt = max; m_dir = GetCacheDirectory(folderName.ToLower()); m_metaFilePath = CFileManager.CombinePath(m_dir, folderName.ToLower() + ".bytes"); m_fileExtension = fileExtension; m_cachedFileInfoSet = new CCachedFileInfoSet(); MakeDirReady(); if (CFileManager.IsFileExist(m_metaFilePath)) { byte[] buffer = CFileManager.LockFileBuffer(); try { uint fileLength = CFileManager.ReadFile(m_metaFilePath, buffer, (uint)buffer.Length); int offset = 0; int ret = m_cachedFileInfoSet.Read(buffer, offset, fileLength); if (ret < 0) //读取出错时,删除所有文件 { Debug.LogError("读取出错,删除所有文件"); CFileManager.ClearDirectory(m_dir); } } finally { CFileManager.UnLockFileBuffer(); } } }
public bool ClearCachePath() { string[] fileExtensionFilter = new string[] { ".json", ".res", ".bytes", ".apk" }; string[] folderFilter = new string[] { CFileManager.s_ifsExtractFolder }; return(CFileManager.ClearDirectory(CFileManager.GetCachePath(), fileExtensionFilter, folderFilter)); }