From 53703efd287ded0023fd212cff641fccb4267f72 Mon Sep 17 00:00:00 2001 From: Sergii T Date: Tue, 11 Oct 2022 15:26:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=87=D1=83=D1=82=D0=BE=D0=BA=20rescan=5Fpathes=20?= =?UTF-8?q?=D0=A1=D0=BC=D1=8B=D1=81=D0=BB=20rescan=5Fpathes=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE=20=D0=B1=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20FS=20=D1=81=20=D1=80=D0=B5=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=BC=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=D0=BC=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=B4=D0=B8=D1=81=D0=BA=D0=B5,=20=D0=B8=20?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=20=D0=BD=D0=B5=D0=BB=D1=8C=D0=B7=D1=8F=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0=D1=82=D1=8C=20=D0=B5?= =?UTF-8?q?=D1=81=D0=BB=D0=B8=20=D0=B2=D1=81=D0=B5=20=D0=BB=D0=B5=D0=B6?= =?UTF-8?q?=D0=B8=D1=82=20=D0=B2=20=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ogsr_engine/xrCore/LocatorAPI.cpp | 59 ++++++++------------ ogsr_engine/xrCore/LocatorAPI.h | 6 +- ogsr_engine/xrCore/LocatorAPI_defs.h | 1 + ogsr_engine/xrGame/fs_registrator_script.cpp | 2 +- 4 files changed, 27 insertions(+), 41 deletions(-) diff --git a/ogsr_engine/xrCore/LocatorAPI.cpp b/ogsr_engine/xrCore/LocatorAPI.cpp index 85614f87a8..46396b1b53 100644 --- a/ogsr_engine/xrCore/LocatorAPI.cpp +++ b/ogsr_engine/xrCore/LocatorAPI.cpp @@ -15,6 +15,8 @@ #include "file_stream_reader.h" #include "trivial_encryptor.h" +#include ; + constexpr u32 BIG_FILE_READER_WINDOW_SIZE = 1024 * 1024; std::unique_ptr xr_FS; @@ -387,7 +389,7 @@ void CLocatorAPI::ProcessOne(LPCSTR path, const _finddata_t& F) return; strcat_s(N, "\\"); Register(N, 0xffffffff, 0, 0, F.size, F.size, (u32)F.time_write); - Recurse(N); + RecurseScanPhysicalPath(N); } else { @@ -432,7 +434,7 @@ bool ignore_path(const char* _path) return true; } -bool CLocatorAPI::Recurse(const char* path, const bool log_if_found) +bool CLocatorAPI::RecurseScanPhysicalPath(const char* path, const bool log_if_found) { _finddata_t sFile; intptr_t hFile; @@ -568,31 +570,6 @@ void CLocatorAPI::_initialize(u32 flags, LPCSTR target_folder, LPCSTR fs_name) } else { - /* - LPCSTR fs_ltx = (fs_name&&fs_name[0])?fs_name:FSLTX; - F = r_open(fs_ltx); - if (!F&&m_Flags.is(flScanAppRoot)) - F = r_open("$app_root$",fs_ltx); - - if (!F) - { - string_path tmpAppPath{}; - strcpy_s(tmpAppPath, Core.ApplicationPath); - if (xr_strlen(tmpAppPath)) - { - tmpAppPath[xr_strlen(tmpAppPath)-1] = 0; - if (strrchr(tmpAppPath, '\\')) - *(strrchr(tmpAppPath, '\\')+1) = 0; - - FS_Path* pFSRoot = FS.get_path("$fs_root$"); - pFSRoot->_set_root (tmpAppPath); - rescan_path (pFSRoot->m_Path, pFSRoot->m_Flags.is(FS_Path::flRecurse)); - } - F = r_open("$fs_root$",fs_ltx); - } - - Log ("using fs-ltx",fs_ltx); - */ CHECK_OR_EXIT(pFSltx, make_string("Cannot open file \"%s\".\nCheck your working folder.", fs_ltx)); // append all pathes string_path id, root, add, def, capt; @@ -642,9 +619,9 @@ void CLocatorAPI::_initialize(u32 flags, LPCSTR target_folder, LPCSTR fs_name) bNoRecurse = !(fl & FS_Path::flRecurse); #ifdef RESTRICT_GAMEDATA if (!strcmp(id, "$app_data_root$") || !strcmp(id, "$game_saves$") || !strcmp(id, "$logs$") || !strcmp(id, "$screenshots$")) - Recurse(P->m_Path); + RecurseScanPhysicalPath(P->m_Path); #else - Recurse(P->m_Path, true); + RecurseScanPhysicalPath(P->m_Path, true); #endif I = pathes.emplace(xr_strdup(id), P); #ifndef DEBUG @@ -681,7 +658,7 @@ void CLocatorAPI::_initialize(u32 flags, LPCSTR target_folder, LPCSTR fs_name) if (pAppdataPath) { pAppdataPath->_set_root(c_newAppPathRoot); - rescan_path(pAppdataPath->m_Path, pAppdataPath->m_Flags.is(FS_Path::flRecurse)); + rescan_physical_path(pAppdataPath->m_Path, pAppdataPath->m_Flags.is(FS_Path::flRecurse)); } } //----------------------------------------------------------- @@ -1228,7 +1205,7 @@ FS_Path* CLocatorAPI::append_path(LPCSTR path_alias, LPCSTR root, LPCSTR add, BO VERIFY(false == path_exist(path_alias)); FS_Path* P = xr_new(root, add, LPCSTR(0), LPCSTR(0), 0); bNoRecurse = !recursive; - Recurse(P->m_Path); + RecurseScanPhysicalPath(P->m_Path); pathes.emplace(xr_strdup(path_alias), P); return P; } @@ -1280,7 +1257,7 @@ void CLocatorAPI::set_file_age(LPCSTR nm, u32 age) } } -void CLocatorAPI::rescan_path(LPCSTR full_path, BOOL bRecurse) +void CLocatorAPI::rescan_physical_path(LPCSTR full_path, BOOL bRecurse) { file desc; desc.name = full_path; @@ -1308,10 +1285,10 @@ void CLocatorAPI::rescan_path(LPCSTR full_path, BOOL bRecurse) files.erase(cur_item); } bNoRecurse = !bRecurse; - Recurse(full_path); + RecurseScanPhysicalPath(full_path); } -void CLocatorAPI::rescan_pathes() +void CLocatorAPI::rescan_physical_pathes() { m_Flags.set(flNeedRescan, FALSE); for (PathPairIt p_it = pathes.begin(); p_it != pathes.end(); p_it++) @@ -1319,7 +1296,15 @@ void CLocatorAPI::rescan_pathes() FS_Path* P = p_it->second; if (P->m_Flags.is(FS_Path::flNeedRescan)) { - rescan_path(P->m_Path, P->m_Flags.is(FS_Path::flRecurse)); + std::string filepath{P->m_Path}; + bool filepathExists = std::filesystem::exists(filepath); + + // рескан нужно делать только для реальных каталогов на диске + if (filepathExists) + { + rescan_physical_path(P->m_Path, P->m_Flags.is(FS_Path::flRecurse)); + } + P->m_Flags.set(FS_Path::flNeedRescan, FALSE); } } @@ -1332,7 +1317,7 @@ void CLocatorAPI::unlock_rescan() m_iLockRescan--; VERIFY(m_iLockRescan >= 0); if ((0 == m_iLockRescan) && m_Flags.is(flNeedRescan)) - rescan_pathes(); + rescan_physical_pathes(); } void CLocatorAPI::check_pathes() @@ -1340,7 +1325,7 @@ void CLocatorAPI::check_pathes() if (m_Flags.is(flNeedRescan) && (0 == m_iLockRescan)) { lock_rescan(); - rescan_pathes(); + rescan_physical_pathes(); unlock_rescan(); } } diff --git a/ogsr_engine/xrCore/LocatorAPI.h b/ogsr_engine/xrCore/LocatorAPI.h index 0b37e9612e..6114be8493 100644 --- a/ogsr_engine/xrCore/LocatorAPI.h +++ b/ogsr_engine/xrCore/LocatorAPI.h @@ -47,7 +47,7 @@ class XRCORE_API CLocatorAPI DEFINE_VECTOR(archive, archives_vec, archives_it); int m_iLockRescan; - void rescan_path(LPCSTR full_path, BOOL bRecurse); + void rescan_physical_path(LPCSTR full_path, BOOL bRecurse); void check_pathes(); files_set files; @@ -60,7 +60,7 @@ class XRCORE_API CLocatorAPI void Register(LPCSTR name, u32 vfs, u32 crc, u32 ptr, u32 size_real, u32 size_compressed, u32 modif); void ProcessArchive(LPCSTR path, LPCSTR base_path = NULL); void ProcessOne(LPCSTR path, const _finddata_t& F); - bool Recurse(const char* path, const bool log_if_found = false); + bool RecurseScanPhysicalPath(const char* path, const bool log_if_found = false); files_it file_find_it(LPCSTR n); @@ -155,7 +155,7 @@ class XRCORE_API CLocatorAPI void auth_runtime(void*);*/ // editor functions - void rescan_pathes(); + void rescan_physical_pathes(); void lock_rescan(); void unlock_rescan(); }; diff --git a/ogsr_engine/xrCore/LocatorAPI_defs.h b/ogsr_engine/xrCore/LocatorAPI_defs.h index 95dd8ec62a..fcd627dc25 100644 --- a/ogsr_engine/xrCore/LocatorAPI_defs.h +++ b/ogsr_engine/xrCore/LocatorAPI_defs.h @@ -6,6 +6,7 @@ enum FS_List FS_ListFolders = (1 << 1), FS_ClampExt = (1 << 2), FS_RootOnly = (1 << 3), + FS_forcedword = u32(-1) }; diff --git a/ogsr_engine/xrGame/fs_registrator_script.cpp b/ogsr_engine/xrGame/fs_registrator_script.cpp index 7dc297d231..06648f0649 100644 --- a/ogsr_engine/xrGame/fs_registrator_script.cpp +++ b/ogsr_engine/xrGame/fs_registrator_script.cpp @@ -103,7 +103,7 @@ FS_file_list_ex::FS_file_list_ex(LPCSTR path, u32 flags, LPCSTR mask) FS_Path* P = FS.get_path(path); P->m_Flags.set(FS_Path::flNeedRescan, TRUE); FS.m_Flags.set(CLocatorAPI::flNeedCheck, TRUE); - FS.rescan_pathes(); + FS.rescan_physical_pathes(); FS_FileSet files; FS.file_list(files, path, flags, mask);