bool CResourceScript::CheckForChange() { ADDTOCALLSTACK("CResourceScript::CheckForChange"); // Get Size/Date info on the file to see if it has changed. time_t dateChange; DWORD dwSize; if ( ! CFileList::ReadFileInfo( GetFilePath(), dateChange, dwSize )) { DEBUG_ERR(( "Can't get stats info for file '%s'\n", static_cast<LPCTSTR>(GetFilePath()) )); return false; } bool fChange = false; // See If the script has changed if ( ! IsFirstCheck()) { if ( m_dwSize != dwSize || m_dateChange != dateChange ) { g_Log.Event(LOGL_WARN, "Resource '%s' changed, resync.\n", static_cast<LPCTSTR>(GetFilePath())); fChange = true; } } m_dwSize = dwSize; // Compare to see if this has changed. m_dateChange = dateChange; // real world time/date of last change. return( fChange ); }
void CResourceScript::ReSync() { ADDTOCALLSTACK("CResourceScript::ReSync"); if ( ! IsFirstCheck()) { if ( ! CheckForChange()) return; } if ( ! Open()) return; g_Cfg.LoadResourcesOpen( this ); Close(); }
CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsPageAvail( uint32_t dwPage, DownloadHints* pHints) { if (!m_pDocument) return DataError; if (IsFirstCheck(dwPage)) { m_bCurPageDictLoadOK = false; m_bPageLoadedOK = false; m_bAnnotsLoad = false; m_bNeedDownLoadResource = false; m_objs_array.clear(); m_ObjectSet.clear(); } if (pdfium::ContainsKey(m_pagesLoadState, dwPage)) return DataAvailable; if (m_pLinearized) { if (dwPage == m_pLinearized->GetFirstPageNo()) { DocAvailStatus nRet = CheckLinearizedFirstPage(dwPage, pHints); if (nRet == DataAvailable) m_pagesLoadState.insert(dwPage); return nRet; } DocAvailStatus nResult = CheckLinearizedData(pHints); if (nResult != DataAvailable) return nResult; if (m_pHintTables) { nResult = m_pHintTables->CheckPage(dwPage, pHints); if (nResult != DataAvailable) return nResult; m_pagesLoadState.insert(dwPage); return GetPage(dwPage) ? DataAvailable : DataError; } if (m_bMainXRefLoadedOK) { if (m_bTotalLoadPageTree) { if (!LoadPages(pHints)) return DataNotAvailable; } else { if (!m_bCurPageDictLoadOK && !CheckPage(dwPage, pHints)) return DataNotAvailable; } } else { if (!LoadAllFile(pHints)) return DataNotAvailable; m_pDocument->GetParser()->RebuildCrossRef(); ResetFirstCheck(dwPage); return DataAvailable; } } else { if (!m_bTotalLoadPageTree && !m_bCurPageDictLoadOK && !CheckPage(dwPage, pHints)) { return DataNotAvailable; } } if (m_bHaveAcroForm && !m_bAcroFormLoad) { if (!CheckAcroFormSubObject(pHints)) return DataNotAvailable; m_bAcroFormLoad = true; } if (!m_bPageLoadedOK) { if (m_objs_array.empty()) { m_ObjectSet.clear(); FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage); m_pPageDict = m_pDocument->GetPage(safePage.ValueOrDie()); if (!m_pPageDict) { ResetFirstCheck(dwPage); // This is XFA page. return DataAvailable; } std::vector<CPDF_Object*> obj_array; obj_array.push_back(m_pPageDict); if (!AreObjectsAvailable(obj_array, true, pHints, m_objs_array)) return DataNotAvailable; m_objs_array.clear(); } else { std::vector<CPDF_Object*> new_objs_array; if (!AreObjectsAvailable(m_objs_array, false, pHints, new_objs_array)) { m_objs_array = new_objs_array; return DataNotAvailable; } } m_objs_array.clear(); m_bPageLoadedOK = true; } if (!m_bAnnotsLoad) { if (!CheckPageAnnots(dwPage, pHints)) return DataNotAvailable; m_bAnnotsLoad = true; } if (m_pPageDict && !m_bNeedDownLoadResource) { m_pPageResource = m_pPageDict->GetObjectFor("Resources"); m_bNeedDownLoadResource = m_pPageResource || HaveResourceAncestor(m_pPageDict); } if (m_bNeedDownLoadResource) { if (!CheckResources(pHints)) return DataNotAvailable; m_bNeedDownLoadResource = false; } m_bPageLoadedOK = false; m_bAnnotsLoad = false; m_bCurPageDictLoadOK = false; ResetFirstCheck(dwPage); m_pagesLoadState.insert(dwPage); const bool is_page_valid = ValidatePage(dwPage); (void)is_page_valid; ASSERT(is_page_valid); return DataAvailable; }