bool GitStatus::IsExistIndexLockFile(CString sDirName) { if (!PathIsDirectory(sDirName)) { int x = sDirName.ReverseFind(_T('\\')); if (x < 2) return false; sDirName = sDirName.Left(x); } for (;;) { if (PathFileExists(CombinePath(sDirName, _T(".git")))) { if (PathFileExists(g_AdminDirMap.GetAdminDirConcat(sDirName, _T("index.lock")))) return true; return false; } int x = sDirName.ReverseFind(_T('\\')); if (x < 2) return false; sDirName = sDirName.Left(x); } }
// Checks whether there is a ".agent.db". If yes, the function // sets "szRootPath" and "szDataPath" in the storage structure // and returns ERROR_SUCCESS int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory) { QUERY_KEY AgentFile; TCHAR * szFilePath; size_t nLength = 0; char * szValue; int nError = ERROR_FILE_NOT_FOUND; // Create the full name of the .agent.db file szFilePath = CombinePath(szDirectory, _T(".agent.db")); if(szFilePath != NULL) { // Load the file to memory nError = LoadTextFile(szFilePath, &AgentFile); if(nError == ERROR_SUCCESS) { // Extract the data directory from the ".agent.db" file szValue = ExtractStringVariable(&AgentFile, "data_dir", &nLength); if(szValue != NULL) { hs->szRootPath = CascNewStr(szDirectory, 0); hs->szDataPath = CombinePathAndString(szDirectory, szValue, nLength); nError = (hs->szDataPath != NULL) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY; } // Free the loaded blob FreeCascBlob(&AgentFile); } // Freee the file path CASC_FREE(szFilePath); } return nError; }
static int CheckDataDirectory(TCascStorage * hs, TCHAR * szDirectory) { TCHAR * szDataPath; int nError = ERROR_FILE_NOT_FOUND; // Try all known subdirectories for(size_t i = 0; DataDirs[i] != NULL; i++) { // Create the eventual data path szDataPath = CombinePath(szDirectory, DataDirs[i]); if(szDataPath != NULL) { // Does that directory exist? if(DirectoryExists(szDataPath)) { hs->szDataPath = szDataPath; return ERROR_SUCCESS; } // Free the data path CASC_FREE(szDataPath); } } return nError; }
//-------------------------------------------------------------------------------------------------- std::string FindFile ( const std::string& name, ///< The file path. const std::list<std::string>& searchPaths ///< List of directory paths to search in. ) //-------------------------------------------------------------------------------------------------- { if (legato::IsAbsolutePath(name)) { if (legato::FileExists(name) == false) { return ""; } return name; } for (const auto& path : searchPaths) { if (legato::DirectoryExists(path)) { std::string newPath = CombinePath(path, name); if (legato::FileExists(newPath)) { return newPath; } } } return ""; }
static int EnsureDataStreamIsOpen(TCascFile * hf) { TCascStorage * hs = hf->hs; TFileStream * pStream = NULL; TCHAR * szDataFile; TCHAR szPlainName[0x40]; // If the file is not open yet, do it if(hs->DataFileArray[hf->ArchiveIndex] == NULL) { // Prepare the name of the data file _stprintf(szPlainName, _T("data.%03u"), hf->ArchiveIndex); szDataFile = CombinePath(hs->szIndexPath, szPlainName); // Open the data file if(szDataFile != NULL) { // Open the stream pStream = FileStream_OpenFile(szDataFile, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE); hs->DataFileArray[hf->ArchiveIndex] = pStream; CASC_FREE(szDataFile); } } // Return error or success hf->pStream = hs->DataFileArray[hf->ArchiveIndex]; return (hf->pStream != NULL) ? ERROR_SUCCESS : ERROR_FILE_NOT_FOUND; }
void Model_IO::LoadMaterial(Material& material, BinaryReader& reader, const achar* path) { material.Type = reader.Get<int32_t>(); if (material.Type == 1) { auto path = reader.Get<astring>(); } else { material.OriginalColorTexture = reader.Get<astring>(); material.OriginalNormalTexture = reader.Get<astring>(); material.OriginalMetalnessTexture = reader.Get<astring>(); if (material.OriginalColorTexture != astring()) material.ColorTexture = CombinePath(path, material.OriginalColorTexture.c_str()); if (material.OriginalNormalTexture != astring()) material.NormalTexture = CombinePath(path, material.OriginalNormalTexture.c_str()); if (material.OriginalMetalnessTexture != astring()) material.MetalnessTexture = CombinePath(path, material.OriginalMetalnessTexture.c_str()); } }
void* CSimplisticPluginLoadLogic::LoadPlugin( const CString& rootDir , const CString& moduleName , const CString& groupName , const TVersion* pluginVersion ) {GUCEF_TRACE; CString fullPluginPath = CombinePath( rootDir, moduleName ); fullPluginPath = RelativePath( fullPluginPath ); return LoadModuleDynamicly( fullPluginPath.C_String() ); }
static TCHAR * CheckForIndexDirectory(TCascStorage * hs, const TCHAR * szSubDir) { TCHAR * szIndexPath; // Cpmbine the index path szIndexPath = CombinePath(hs->szDataPath, szSubDir); if(DirectoryExists(szIndexPath)) { hs->szIndexPath = szIndexPath; return hs->szIndexPath; } CASC_FREE(szIndexPath); return NULL; }
//-------------------------------------------------------------------------------------------------- std::string AbsolutePath ( const std::string& path ///< The original path, which could be absolute or relative. ) //-------------------------------------------------------------------------------------------------- { if (IsAbsolutePath(path)) { return path; } else { return CombinePath(GetWorkingDir(), path); } }
void FileBundle::ImportCompositeBundle(const YAML::Node& config) { string dir = vars_->Expand(config["dir"]); vector<string> dir_files = GetFileList(dir); vector<string> include_masks; auto include_node = config["include"]; if (include_node.IsDefined()) { for (auto m = include_node.begin(); m != include_node.end(); ++m) { include_masks.push_back(m->as<string>()); } } vector<string> exclude_masks; auto exclude_node = config["exclude"]; if (exclude_node.IsDefined()) { for (auto m = exclude_node.begin(); m != exclude_node.end(); ++m) { exclude_masks.push_back(m->as<string>()); } } for (auto i = dir_files.begin(); i != dir_files.end(); ++i) { const string& file_name = *i; if (include_masks.empty() || PathMatchesWildcard(file_name, include_masks)) { if (!PathMatchesWildcard(file_name, exclude_masks)) { string file_path = CombinePath(dir, file_name); FileItemPtr file = make_shared<FileItem>(file_path); file->install_location = install_location_; files.push_back(file); } } } }
// Checks whether there is a ".build.info" or ".build.db". // If yes, the function sets "szDataPath" and "szIndexPath" // in the storage structure and returns ERROR_SUCCESS int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory) { TFileStream * pStream; TCHAR * szBuildFile; int nError = ERROR_FILE_NOT_FOUND; // Try to find any of the root files used in the history for (size_t i = 0; BuildTypes[i].szFileName != NULL; i++) { // Create the full name of the .agent.db file szBuildFile = CombinePath(szDirectory, BuildTypes[i].szFileName); if (szBuildFile != NULL) { // Attempt to open the file pStream = FileStream_OpenFile(szBuildFile, STREAM_FLAG_READ_ONLY); if (pStream != NULL) { // Free the stream FileStream_Close(pStream); // Check for the data directory nError = CheckDataDirectory(hs, szDirectory); if (nError == ERROR_SUCCESS) { hs->szBuildFile = szBuildFile; hs->BuildFileType = BuildTypes[i].BuildFileType; return ERROR_SUCCESS; } } CASC_FREE(szBuildFile); } } return nError; }
int LoadBuildInfo(TCascStorage * hs) { TCHAR * szAgentFile; TCHAR * szInfoFile; void * pvListFile; bool bBuildConfigComplete = false; int nError = ERROR_SUCCESS; // Since HOTS build 30027, the game uses .build.info file for storage info if(bBuildConfigComplete == false) { szInfoFile = CombinePath(hs->szRootPath, _T(".build.info")); if(szInfoFile != NULL) { pvListFile = ListFile_OpenExternal(szInfoFile); if(pvListFile != NULL) { // Parse the info file nError = ParseInfoFile(hs, pvListFile); if(nError == ERROR_SUCCESS) bBuildConfigComplete = true; ListFile_Free(pvListFile); } CASC_FREE(szInfoFile); } } // If the info file has not been loaded, try the legacy .build.db if(bBuildConfigComplete == false) { szAgentFile = CombinePath(hs->szRootPath, _T(".build.db")); if(szAgentFile != NULL) { pvListFile = ListFile_OpenExternal(szAgentFile); if(pvListFile != NULL) { nError = ParseAgentFile(hs, pvListFile); if(nError == ERROR_SUCCESS) bBuildConfigComplete = true; ListFile_Free(pvListFile); } CASC_FREE(szAgentFile); } } // If the .build.info OR .build.db file has been loaded, // proceed with loading the CDN config file and CDN build file if(nError == ERROR_SUCCESS && bBuildConfigComplete) { // Load the configuration file pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnConfigKey); if(pvListFile != NULL) { nError = LoadCdnConfigFile(hs, pvListFile); ListFile_Free(pvListFile); } else nError = ERROR_FILE_NOT_FOUND; } // Load the build file if(nError == ERROR_SUCCESS && bBuildConfigComplete) { pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnBuildKey); if(pvListFile != NULL) { nError = LoadCdnBuildFile(hs, pvListFile); ListFile_Free(pvListFile); } else nError = ERROR_FILE_NOT_FOUND; } // Fill the index directory if(nError == ERROR_SUCCESS) { // First, check for more common "data" subdirectory if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("data"))) != NULL) return ERROR_SUCCESS; // Second, try the "darch" subdirectory (older builds of HOTS - Alpha) if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("darch"))) != NULL) return ERROR_SUCCESS; nError = ERROR_FILE_NOT_FOUND; } return nError; }
//-------------------------------------------------------------------------------------------------- void ParseComponent ( Component* componentPtr, ///< The Component object to populate. const BuildParams_t& buildParams ///< Build parameters obtained from the command line. ) //-------------------------------------------------------------------------------------------------- { ComponentPtr = componentPtr; BuildParamsPtr = &buildParams; // Open the component's Component.cdef file for reading. std::string path = FindComponent(componentPtr->Path(), buildParams.SourceDirs()); if (path == "") { throw Exception("Couldn't find component '" + componentPtr->Path() + "'."); } componentPtr->Path(path); std::string cdefFilePath = CombinePath(path, "/Component.cdef"); FILE* file = fopen(cdefFilePath.c_str(), "r"); if (file == NULL) { int error = errno; std::stringstream errorMessage; errorMessage << "Failed to open file '" << cdefFilePath << "'." << " Errno = " << error << "(" << strerror(error) << ")."; throw Exception(errorMessage.str()); } if (buildParams.IsVerbose()) { std::cout << "Parsing '" << cdefFilePath << "'\n"; } // Tell the parser to reset itself and connect to the new file stream for future parsing. cyy_FileName = cdefFilePath.c_str(); cyy_IsVerbose = (BuildParamsPtr->IsVerbose() ? 1 : 0); cyy_EndOfFile = 0; cyy_ErrorCount = 0; cyy_set_lineno(1); cyy_restart(file); // Until the parsing is done, int parsingResult; do { // Start parsing. parsingResult = cyy_parse(); } while ((parsingResult != 0) && (!cyy_EndOfFile)); // Close the file fclose(file); // Halt if there were errors. if (cyy_ErrorCount > 0) { throw Exception("Errors encountered while parsing '" + cdefFilePath + "'."); } ComponentPtr = NULL; if (buildParams.IsVerbose()) { std::cout << "Finished parsing '" << cdefFilePath << "'\n"; } // Recursively, for each of the new component's sub-components, for (auto& mapEntry : componentPtr->SubComponents()) { mapEntry.second = Component::FindComponent(mapEntry.first); // If the sub-component has not yet been parsed, create an object for it and parse it now. if (mapEntry.second == NULL) { mapEntry.second = Component::CreateComponent(mapEntry.first); ParseComponent(mapEntry.second, buildParams); } } }
int CGitIndexList::GetStatus(const CString& gitdir, CString path, git_wc_status_kind* status, BOOL IsFull, BOOL /*IsRecursive*/, FILL_STATUS_CALLBACK callback, void *pData, CGitHash *pHash, bool * assumeValid, bool * skipWorktree) { __int64 time, filesize = 0; bool isDir = false; if (!status) return 0; git_wc_status_kind dirstatus = git_wc_status_none; int result; if (path.IsEmpty()) result = CGit::GetFileModifyTime(gitdir, &time, &isDir); else result = CGit::GetFileModifyTime(CombinePath(gitdir, path), &time, &isDir, &filesize); if (result) { *status = git_wc_status_deleted; if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, path), git_wc_status_deleted, false, pData, *assumeValid, *skipWorktree); return 0; } if (!isDir) { GetFileStatus(gitdir, path, status, time, filesize, callback, pData, pHash, assumeValid, skipWorktree); return 0; } if (!path.IsEmpty() && path.Right(1) != _T('\\')) path += _T('\\'); int len = path.GetLength(); for (auto it = cbegin(), itend = cend(); it != itend; ++it) { if (!((*it).m_FileName.GetLength() > len && wcsncmp((*it).m_FileName, path, len) == 0)) continue; if (!IsFull) { *status = git_wc_status_normal; if (callback) callback(CombinePath(gitdir, path), *status, false, pData, ((*it).m_Flags & GIT_IDXENTRY_VALID) && !((*it).m_FlagsExtended & GIT_IDXENTRY_SKIP_WORKTREE), ((*it).m_FlagsExtended & GIT_IDXENTRY_SKIP_WORKTREE) != 0); return 0; } result = CGit::GetFileModifyTime(CombinePath(gitdir, (*it).m_FileName), &time, nullptr, &filesize); if (result) continue; *status = git_wc_status_none; if (assumeValid) *assumeValid = false; if (skipWorktree) *skipWorktree = false; GetFileStatus(gitdir, (*it).m_FileName, status, time, filesize, callback, pData, nullptr, assumeValid, skipWorktree); // if a file is assumed valid, we need to inform the caller, otherwise the assumevalid flag might not get to the explorer on first open of a repository if (callback && assumeValid && skipWorktree && (*assumeValid || *skipWorktree)) callback(CombinePath(gitdir, path), *status, false, pData, *assumeValid, *skipWorktree); if (*status != git_wc_status_none) { if (dirstatus == git_wc_status_none) dirstatus = git_wc_status_normal; if (*status != git_wc_status_normal) dirstatus = git_wc_status_modified; } } /* End For */ if (dirstatus != git_wc_status_none) *status = dirstatus; else *status = git_wc_status_unversioned; if (callback) callback(CombinePath(gitdir, path), *status, false, pData, false, false); return 0; }
int CGitIndexList::GetFileStatus(const CString &gitdir, const CString &pathorg, git_wc_status_kind *status, __int64 time, __int64 filesize, FILL_STATUS_CALLBACK callback, void *pData, CGitHash *pHash, bool * assumeValid, bool * skipWorktree) { if (!status) return 0; CString path = pathorg; path.MakeLower(); int index = SearchInSortVector(*this, path, -1); if (index < 0) { *status = git_wc_status_unversioned; if (pHash) pHash->Empty(); if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, pathorg), *status, false, pData, *assumeValid, *skipWorktree); return 0; } // skip-worktree has higher priority than assume-valid if (at(index).m_FlagsExtended & GIT_IDXENTRY_SKIP_WORKTREE) { *status = git_wc_status_normal; if (skipWorktree) *skipWorktree = true; } else if (at(index).m_Flags & GIT_IDXENTRY_VALID) { *status = git_wc_status_normal; if (assumeValid) *assumeValid = true; } else if (filesize != at(index).m_Size) *status = git_wc_status_modified; else if (time == at(index).m_ModifyTime) *status = git_wc_status_normal; else if (repository && filesize < m_iMaxCheckSize) { git_oid actual; CStringA fileA = CUnicodeUtils::GetMulti(pathorg, CP_UTF8); m_critRepoSec.Lock(); // prevent concurrent access to repository instance and especially filter-lists if (!git_repository_hashfile(&actual, repository, fileA, GIT_OBJ_BLOB, nullptr) && !git_oid_cmp(&actual, (const git_oid*)at(index).m_IndexHash.m_hash)) { at(index).m_ModifyTime = time; *status = git_wc_status_normal; } else *status = git_wc_status_modified; m_critRepoSec.Unlock(); } else *status = git_wc_status_modified; if (at(index).m_Flags & GIT_IDXENTRY_STAGEMASK) *status = git_wc_status_conflicted; else if (at(index).m_FlagsExtended & GIT_IDXENTRY_INTENT_TO_ADD) *status = git_wc_status_added; if (pHash) *pHash = at(index).m_IndexHash; if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, pathorg), *status, false, pData, *assumeValid, *skipWorktree); return 0; }
int CGitIgnoreList::CheckIgnore(const CString &path, const CString &projectroot, bool isDir) { CString temp = CombinePath(projectroot, path); temp.Replace(_T('/'), _T('\\')); CStringA patha = CUnicodeUtils::GetMulti(path, CP_UTF8); patha.Replace('\\', '/'); int type = 0; if (isDir) { type = DT_DIR; // strip directory name // we do not need to check for a .ignore file inside a directory we might ignore int i = temp.ReverseFind(_T('\\')); if (i >= 0) temp.Truncate(i); } else { type = DT_REG; int x = temp.ReverseFind(_T('\\')); if (x >= 2) temp.Truncate(x); } int pos = patha.ReverseFind('/'); const char * base = (pos >= 0) ? ((const char*)patha + pos + 1) : patha; int ret = -1; CAutoReadLock lock(m_SharedMutex); while (!temp.IsEmpty()) { CString tempOrig = temp; temp += _T("\\.git"); if (CGit::GitPathFileExists(temp)) { CString gitignore = temp; gitignore += _T("ignore"); if ((ret = CheckFileAgainstIgnoreList(gitignore, patha, base, type)) != -1) break; CString adminDir = g_AdminDirMap.GetAdminDir(tempOrig); CString wcglobalgitignore = adminDir; wcglobalgitignore += _T("info\\exclude"); if ((ret = CheckFileAgainstIgnoreList(wcglobalgitignore, patha, base, type)) != -1) break; CString excludesFile = m_CoreExcludesfiles[adminDir]; if (!excludesFile.IsEmpty()) ret = CheckFileAgainstIgnoreList(excludesFile, patha, base, type); break; } temp += _T("ignore"); if ((ret = CheckFileAgainstIgnoreList(temp, patha, base, type)) != -1) break; int found = 0; int i; for (i = temp.GetLength() - 1; i >= 0; i--) { if (temp[i] == _T('\\')) ++found; if (found == 2) break; } temp.Truncate(i); } return ret; }
int GitStatus::EnumDirStatus(const CString &gitdir, const CString &subpath, git_wc_status_kind * status,BOOL IsFul, BOOL IsRecursive, BOOL IsIgnore, FILL_STATUS_CALLBACK callback, void *pData) { if (!status) return 0; CString path = subpath; path.Replace(_T('\\'), _T('/')); if (!path.IsEmpty() && path[path.GetLength() - 1] != _T('/')) path += _T('/'); // Add trail / to show it is directory, not file name. std::vector<CGitFileName> filelist; GetFileList(CombinePath(gitdir, subpath), filelist); g_IndexFileMap.CheckAndUpdate(gitdir,true); g_HeadFileMap.CheckHeadAndUpdate(gitdir); SHARED_INDEX_PTR indexptr = g_IndexFileMap.SafeGet(gitdir); SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir); // new git working tree has no index file if (!indexptr.get()) { for (auto it = filelist.cbegin(); it != filelist.cend(); ++it) { CString casepath = path; casepath += it->m_CaseFileName; bool bIsDir = false; if (!it->m_FileName.IsEmpty() && it->m_FileName[it->m_FileName.GetLength() - 1] == _T('/')) bIsDir = true; if (IsIgnore) { if (g_IgnoreList.CheckIgnoreChanged(gitdir, casepath, bIsDir)) g_IgnoreList.LoadAllIgnoreFile(gitdir, casepath, bIsDir); if (g_IgnoreList.IsIgnore(casepath, gitdir, bIsDir)) *status = git_wc_status_ignored; else if (bIsDir) continue; else *status = git_wc_status_unversioned; } else if (bIsDir) continue; else *status = git_wc_status_unversioned; if (callback) callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false); } return 0; } CString lowcasepath = path; lowcasepath.MakeLower(); for (auto it = filelist.cbegin(), itend = filelist.cend(); it != itend; ++it) { CString onepath(lowcasepath); onepath += it->m_FileName; CString casepath(path); casepath += it->m_CaseFileName; bool bIsDir = false; if (!onepath.IsEmpty() && onepath[onepath.GetLength() - 1] == _T('/')) bIsDir = true; int matchLength = -1; if (bIsDir) matchLength = onepath.GetLength(); int pos = SearchInSortVector(*indexptr, onepath, matchLength); int posintree = SearchInSortVector(*treeptr, onepath, matchLength); if (pos < 0 && posintree < 0) { if (onepath.IsEmpty()) continue; if (!IsIgnore) { *status = git_wc_status_unversioned; if (callback) callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false); continue; } if (g_IgnoreList.CheckIgnoreChanged(gitdir, casepath, bIsDir)) g_IgnoreList.LoadAllIgnoreFile(gitdir, casepath, bIsDir); if (g_IgnoreList.IsIgnore(casepath, gitdir, bIsDir)) *status = git_wc_status_ignored; else *status = git_wc_status_unversioned; if (callback) callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false); } else if (pos < 0 && posintree >= 0) /* check if file delete in index */ { *status = git_wc_status_deleted; if (callback) callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false); } else if (pos >= 0 && posintree < 0) /* Check if file added */ { *status = git_wc_status_added; if (indexptr->at(pos).m_Flags & GIT_IDXENTRY_STAGEMASK) *status = git_wc_status_conflicted; if (callback) callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false); } else { if (onepath.IsEmpty()) continue; if (bIsDir) { *status = git_wc_status_normal; if (callback) callback(CombinePath(gitdir, casepath), *status, bIsDir, pData, false, false); } else { bool assumeValid = false; bool skipWorktree = false; git_wc_status_kind filestatus; GetFileStatus(gitdir, casepath, &filestatus, IsFul, IsRecursive, IsIgnore, callback, pData, &assumeValid, &skipWorktree); } } }/*End of For*/ /* Check deleted file in system */ int start = 0, end = 0; int pos = SearchInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength()); // match path prefix, (sub)folders end with slash std::map<CString, bool> skipWorktreeMap; if (GetRangeInSortVector(*indexptr, lowcasepath, lowcasepath.GetLength(), &start, &end, pos) == 0) { CString oldstring; for (auto it = indexptr->cbegin() + start, itlast = indexptr->cbegin() + end; it <= itlast; ++it) { int commonPrefixLength = lowcasepath.GetLength(); int index = (*it).m_FileName.Find(_T('/'), commonPrefixLength); if (index < 0) index = (*it).m_FileName.GetLength(); else ++index; // include slash at the end for subfolders, so that we do not match files by mistake CString filename = (*it).m_FileName.Mid(commonPrefixLength, index - commonPrefixLength); if (oldstring != filename) { oldstring = filename; if (SearchInSortVector(filelist, filename, filename.GetLength()) < 0) { bool skipWorktree = false; *status = git_wc_status_deleted; if (((*it).m_Flags & GIT_IDXENTRY_SKIP_WORKTREE) != 0) { skipWorktreeMap[filename] = true; skipWorktree = true; *status = git_wc_status_normal; } if (callback) callback(CombinePath(gitdir, (*it).m_FileName), *status, false, pData, false, skipWorktree); } } } } start = end = 0; pos = SearchInSortVector(*treeptr, lowcasepath, lowcasepath.GetLength()); // match path prefix, (sub)folders end with slash if (GetRangeInSortVector(*treeptr, lowcasepath, lowcasepath.GetLength(), &start, &end, pos) == 0) { CString oldstring; for (auto it = treeptr->cbegin() + start, itlast = treeptr->cbegin() + end; it <= itlast; ++it) { int commonPrefixLength = lowcasepath.GetLength(); int index = (*it).m_FileName.Find(_T('/'), commonPrefixLength); if (index < 0) index = (*it).m_FileName.GetLength(); else ++index; // include slash at the end for subfolders, so that we do not match files by mistake CString filename = (*it).m_FileName.Mid(commonPrefixLength, index - commonPrefixLength); if (oldstring != filename && skipWorktreeMap[filename] != true) { oldstring = filename; if (SearchInSortVector(filelist, filename, filename.GetLength()) < 0) { *status = git_wc_status_deleted; if (callback) callback(CombinePath(gitdir, (*it).m_FileName), *status, false, pData, false, false); } } } } return 0; }
// Get VLAN tag pass-through availability of the device void GetVLanSupportStatus(RPC_ENUM_ETH_VLAN_ITEM *e) { BUF *b; char filename[MAX_SIZE]; void *wow; // Validate arguments if (e == NULL) { return; } wow = MsDisableWow64FileSystemRedirection(); // Read the device driver file CombinePath(filename, sizeof(filename), MsGetSystem32Dir(), "drivers"); CombinePath(filename, sizeof(filename), filename, e->DriverName); b = ReadDump(filename); if (b != NULL) { char intel1[] = "VlanFiltering"; char intel2[] = "V\0l\0a\0n\0F\0i\0l\0t\0e\0r\0i\0n\0g"; char intel3[] = "MonitorMode"; char intel4[] = "M\0o\0n\0i\0t\0o\0r\0M\0o\0d\0e"; char intel5[] = "TaggingMode"; char intel6[] = "T\0a\0g\0g\0i\0n\0g\0M\0o\0d\0e"; char broadcom1[] = "PreserveVlanInfoInRxPacket"; char broadcom2[] = "P\0r\0e\0s\0e\0r\0v\0e\0V\0l\0a\0n\0I\0n\0f\0o\0I\0n\0R\0x\0P\0a\0c\0k\0e\0t"; char marvell1[] = "SkDisableVlanStrip"; char marvell2[] = "S\0k\0D\0i\0s\0a\0b\0l\0e\0V\0l\0a\0n\0S\0t\0r\0i\0p"; char *driver_type = ""; if (SearchBin(b->Buf, 0, b->Size, intel1, sizeof(intel1)) != INFINITE || SearchBin(b->Buf, 0, b->Size, intel2, sizeof(intel2)) != INFINITE || SearchBin(b->Buf, 0, b->Size, intel3, sizeof(intel3)) != INFINITE || SearchBin(b->Buf, 0, b->Size, intel4, sizeof(intel4)) != INFINITE || SearchBin(b->Buf, 0, b->Size, intel5, sizeof(intel5)) != INFINITE || SearchBin(b->Buf, 0, b->Size, intel6, sizeof(intel6)) != INFINITE) { driver_type = "Intel"; } else if (SearchBin(b->Buf, 0, b->Size, broadcom1, sizeof(broadcom1)) != INFINITE || SearchBin(b->Buf, 0, b->Size, broadcom2, sizeof(broadcom2)) != INFINITE) { driver_type = "Broadcom"; } else if (SearchBin(b->Buf, 0, b->Size, marvell1, sizeof(marvell1)) != INFINITE || SearchBin(b->Buf, 0, b->Size, marvell2, sizeof(marvell2)) != INFINITE) { driver_type = "Marvell"; } if (IsEmptyStr(driver_type) == false) { StrCpy(e->DriverType, sizeof(e->DriverType), driver_type); e->Support = true; } FreeBuf(b); } MsRestoreWow64FileSystemRedirection(wow); }
bool CPlayerPlaylistBar::ParseMPCPlayList(CString fn) { CString str; CAtlMap<int, CPlaylistItem> pli; CAtlArray<int> idx; CWebTextFile f; if (!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST")) { return false; } if (f.GetEncoding() == CTextFile::ASCII) { f.SetEncoding(CTextFile::ANSI); } CPath base(fn); base.RemoveFileSpec(); while (f.ReadString(str)) { CAtlList<CString> sl; Explode(str, sl, ',', 3); if (sl.GetCount() != 3) { continue; } if (int i = _ttoi(sl.RemoveHead())) { CString key = sl.RemoveHead(); CString value = sl.RemoveHead(); if (key == _T("type")) { pli[i].m_type = (CPlaylistItem::type_t)_ttol(value); idx.Add(i); } else if (key == _T("label")) { pli[i].m_label = value; } else if (key == _T("filename")) { value = CombinePath(base, value); pli[i].m_fns.AddTail(value); } else if (key == _T("subtitle")) { value = CombinePath(base, value); pli[i].m_subs.AddTail(value); } else if (key == _T("video")) { while (pli[i].m_fns.GetCount() < 2) { pli[i].m_fns.AddTail(_T("")); } pli[i].m_fns.GetHead() = value; } else if (key == _T("audio")) { while (pli[i].m_fns.GetCount() < 2) { pli[i].m_fns.AddTail(_T("")); } pli[i].m_fns.GetTail() = value; } else if (key == _T("vinput")) { pli[i].m_vinput = _ttol(value); } else if (key == _T("vchannel")) { pli[i].m_vchannel = _ttol(value); } else if (key == _T("ainput")) { pli[i].m_ainput = _ttol(value); } else if (key == _T("country")) { pli[i].m_country = _ttol(value); } } } qsort(idx.GetData(), idx.GetCount(), sizeof(int), s_int_comp); for (size_t i = 0; i < idx.GetCount(); i++) { m_pl.AddTail(pli[idx[i]]); } return pli.GetCount() > 0; }
int LoadBuildInfo(TCascStorage * hs) { QUERY_KEY InfoFile = {NULL, 0}; QUERY_KEY FileData = {NULL, 0}; TCHAR * szAgentFile; TCHAR * szInfoFile; bool bBuildConfigComplete = false; int nError = ERROR_SUCCESS; // Since HOTS build 30027, the game uses build.info file for storage info if(bBuildConfigComplete == false) { szInfoFile = CombinePath(hs->szRootPath, _T(".build.info")); if(szInfoFile != NULL) { nError = LoadTextFile(szInfoFile, &InfoFile); if(nError == ERROR_SUCCESS) { // Parse the info file nError = ParseInfoFile(hs, &InfoFile); if(nError == ERROR_SUCCESS) bBuildConfigComplete = true; // Free the loaded blob FreeCascBlob(&InfoFile); } CASC_FREE(szInfoFile); } } // If the info file has not been loaded, try the legacy .build.db if(bBuildConfigComplete == false) { szAgentFile = CombinePath(hs->szRootPath, _T(".build.db")); if(szAgentFile != NULL) { nError = LoadTextFile(szAgentFile, &FileData); if(nError == ERROR_SUCCESS) { nError = ParseAgentFile(hs, &FileData); if(nError == ERROR_SUCCESS) bBuildConfigComplete = true; FreeCascBlob(&FileData); } CASC_FREE(szAgentFile); } } // If the .build.info and .build.db file hasn't been loaded, if(nError == ERROR_SUCCESS && bBuildConfigComplete == false) { nError = ERROR_FILE_CORRUPT; } // Load the configuration file if(nError == ERROR_SUCCESS) { nError = FetchAndVerifyConfigFile(hs, &hs->CdnConfigKey, &FileData); if(nError == ERROR_SUCCESS) { nError = LoadCdnConfigFile(hs, &FileData); FreeCascBlob(&FileData); } } // Load the build file if(nError == ERROR_SUCCESS) { nError = FetchAndVerifyConfigFile(hs, &hs->CdnBuildKey, &FileData); if(nError == ERROR_SUCCESS) { nError = LoadCdnBuildFile(hs, &FileData); FreeCascBlob(&FileData); } } // Fill the index directory if(nError == ERROR_SUCCESS) { // First, check for more common "data" subdirectory if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("data"))) != NULL) return ERROR_SUCCESS; // Second, try the "darch" subdirectory (older builds of HOTS - Alpha) if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("darch"))) != NULL) return ERROR_SUCCESS; nError = ERROR_FILE_NOT_FOUND; } return nError; }
int GitStatus::GetFileStatus(const CString& gitdir, CString path, git_wc_status_kind* status, BOOL IsFull, BOOL /*IsRecursive*/, BOOL IsIgnore, FILL_STATUS_CALLBACK callback, void* pData, bool* assumeValid, bool* skipWorktree) { if (!status) return 0; path.Replace(_T('\\'), _T('/')); CString lowcasepath = path; lowcasepath.MakeLower(); git_wc_status_kind st = git_wc_status_none; CGitHash hash; g_IndexFileMap.GetFileStatus(gitdir, path, &st, IsFull, false, callback, pData, &hash, true, assumeValid, skipWorktree); if (st == git_wc_status_conflicted) { *status = st; if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree); return 0; } if (st == git_wc_status_unversioned) { if (!IsIgnore) { *status = git_wc_status_unversioned; if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, path), *status, false, pData, *assumeValid, *skipWorktree); return 0; } if (g_IgnoreList.CheckIgnoreChanged(gitdir, path, false)) g_IgnoreList.LoadAllIgnoreFile(gitdir, path, false); if (g_IgnoreList.IsIgnore(path, gitdir, false)) st = git_wc_status_ignored; *status = st; if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree); return 0; } if ((st == git_wc_status_normal || st == git_wc_status_modified) && IsFull) { g_HeadFileMap.CheckHeadAndUpdate(gitdir); // Check Head Tree Hash SHARED_TREE_PTR treeptr = g_HeadFileMap.SafeGet(gitdir); //add item int start = SearchInSortVector(*treeptr, lowcasepath, -1); if (start < 0) { *status = st = git_wc_status_added; CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) _T(": File miss in head tree %s"), (LPCTSTR)path); if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree); return 0; } // staged and not commit if (treeptr->at(start).m_Hash != hash) { *status = st = git_wc_status_modified; if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree); return 0; } } *status = st; if (callback && assumeValid && skipWorktree) callback(CombinePath(gitdir, path), st, false, pData, *assumeValid, *skipWorktree); return 0; }