bool CPFCManager::GetFromCache(const CStdString& strFile, sFileMap& item, bool bAutoCache) { struct __stat64 sStatData = { }; CLog::Log(LOGDEBUG, "CPFCManager::%s: Working: %s...", __FUNCTION__, strFile.c_str()); for (VECPFCFILESMAP::iterator it = m_filesCache.begin(); it != m_filesCache.end(); ++it) { if (strFile == it->strPFCFileName) { if (CFile::Stat(strFile, &sStatData)) { CLog::Log(LOGDEBUG, "CPFCManager::%s: failed to stat file %s", __FUNCTION__, strFile.c_str()); return false; } if (sStatData.st_mtime == it->st_modtime) { item = *it; return true; } CLog::Log(LOGDEBUG, "CPFCManager::%s: %s outdated...", __FUNCTION__, strFile.c_str()); m_filesCache.erase(it); } } CLog::Log(LOGDEBUG, "CPFCManager::%s: %s not in cache...", __FUNCTION__, strFile.c_str()); if (bAutoCache) return AppendToCache(strFile, item); return false; }
bool MCStreamCache::ReadFromStream(void *p_buffer, uint32_t p_length, uint32_t &r_read) { bool t_success = true; t_success = m_source_stream->Read(p_buffer, p_length, r_read); uint32_t t_written = 0; if (t_success) t_success = AppendToCache(p_buffer, r_read, t_written); if (t_success) t_success = t_written == r_read; return t_success; }