void CFlowGraphModuleManager::RescanModuleNames(bool bGlobal) { CryFixedStringT<512> path = ""; if(bGlobal) { path = PathUtil::GetGameFolder().c_str(); path += "\\Libs\\"; } else { if(gEnv->IsEditor()) { char *levelName; char *levelPath; gEnv->pGame->GetIGameFramework()->GetEditorLevel(&levelName, &levelPath); path = levelPath; } else { ILevel *pLevel = gEnv->pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel(); if (pLevel) { path = pLevel->GetLevelInfo()->GetPath(); } } } if(false == path.empty()) { path += MODULE_FOLDER_NAME; ScanFolder(path, bGlobal); } }
void CommunicationVoiceLibrary::ScanFolder(const char* folderName, bool recursing) { string folder(PathUtil::MakeGamePath(string(folderName))); folder += "/"; string searchString(folder + "*.xml"); _finddata_t fd; intptr_t handle = 0; ICryPak *pPak = gEnv->pCryPak; handle = pPak->FindFirst(searchString.c_str(), &fd); if (handle > -1) { do { if (!strcmp(fd.name, ".") || !strcmp(fd.name, "..")) continue; if (fd.attrib & _A_SUBDIR) ScanFolder(folder + fd.name, true); else LoadFromFile(folder + fd.name); } while (pPak->FindNext(handle, &fd) >= 0); pPak->FindClose(handle); } if (!recursing) stl::push_back_unique(m_folderNames, folderName); }
void CommunicationVoiceLibrary::Reload() { m_testManager->Reset(); m_libraries.clear(); for (uint32 i = 0; i < m_folderNames.size(); ++i) ScanFolder(m_folderNames[i].c_str(), false); }
void ATheHUD::InitWidgets() { if( Init ) return; Init = 1; LOG( "InitWidgets()" ); // Initialize the widgets that show the player gold, lumber, stone counts. ResourcesPanel::GoldTexture = GoldIconTexture; ResourcesPanel::LumberTexture = LumberIconTexture; ResourcesPanel::StoneTexture = StoneIconTexture; Solid::SolidWhiteTexture = SolidWhiteTexture; SlotPanel::SlotPanelTexture = SlotPanelTexture; StackPanel::StackPanelTexture = VoronoiBackground; AbilitiesPanel::BuildButtonTexture = BuildButtonTexture; Image::NoTextureTexture = NoTextureTexture; GameCanvas::MouseCursorHand = MouseCursorHand; GameCanvas::MouseCursorCrossHairs = MouseCursorCrossHairs; ControlsPanel::PauseButtonTexture = PauseButtonTexture; ControlsPanel::ResumeButtonTexture = ResumeButtonTexture; SidePanel::RightPanelTexture = RightPanelTexture; Minimap::MinimapTexture = MinimapTexture; CostPanel::CostWidgetBackground = VoronoiBackground; Tooltip::TooltipBackgroundTexture = VoronoiBackground; FVector2D canvasSize( Canvas->SizeX, Canvas->SizeY ); ui = new UserInterface( canvasSize ); // Create the panel for containing items/inventory // Map selection screen MapSelectionScreen *mss = ui->mapSelectionScreen = new MapSelectionScreen( TitleLogoTexture, SolidWhiteTexture, MapSlotEntryBackgroundTexture, PortraitTexture, canvasSize, FVector2D( 120, 24 ), largeFont ); ui->titleScreen = new TitleScreen( TitleScreenTexture, canvasSize ); ui->Add( mss ); mss->OKButton->OnMouseDownLeft = [mss](FVector2D mouse) -> EventCode { // OK button clicked, so load the map if there is a selected widget // else display error message if( mss->Selected ) Game->flycam->LoadLevel( FName( *mss->Selected->GetText() ) ); else Game->hud->ui->statusBar->Set( "Select a map to load first" ) ; return NotConsumed; }; ///// // List the maps in the folder at the left side TArray<FAssetData> maps = ScanFolder( "/Game/Maps" ); for( int i = 0; i < maps.Num(); i++ ) ui->mapSelectionScreen->AddText( maps[i].AssetName.ToString(), CenterCenter ); ui->missionObjectivesScreen = new MissionObjectivesScreen( MapSlotEntryBackgroundTexture, MapSlotEntryBackgroundTexture, canvasSize, FVector2D( 300, 100 ), FVector2D( 8, 8 ) ); ui->Add( ui->missionObjectivesScreen ); /// Set the screen's to correct one for the gamestate ui->SetScreen( Game->gm->state ); }
status_t FortuneAccess::SetFolder(const char *folder) { if(!folder) return B_BAD_VALUE; fPath = folder; ScanFolder(); return B_OK; }
bool ConfigReader::ReadConfigs(std::string path){ std::vector<std::string> fileList = ScanFolder(path); if(fileList.size() == 1 && fileList[0].compare("ERROR") == 0){ return false; } if(fileList.size() > 0){ if(HID_DEBUG){ DEBUG_FUNCTION_LINE("Found %d config files\n",fileList.size()); } processFileList(fileList); } return true; }
void CFlowGraphModuleManager::ScanFolder(const string& folderName, bool bGlobal) { _finddata_t fd; intptr_t handle = 0; ICryPak *pPak = gEnv->pCryPak; CryFixedStringT<512> searchString = folderName.c_str(); searchString.append("*.*"); handle = pPak->FindFirst(searchString.c_str(), &fd); CryFixedStringT<512> moduleName(""); string newFolder(""); if (handle > -1) { do { if (!strcmp(fd.name, ".") || !strcmp(fd.name, "..") || (fd.attrib & _A_HIDDEN)) continue; if (fd.attrib & _A_SUBDIR) { newFolder = folderName; newFolder = newFolder + fd.name; newFolder = newFolder + "\\"; ScanFolder(newFolder, bGlobal); } else { moduleName = fd.name; if(!strcmpi(PathUtil::GetExt(moduleName.c_str()), "xml")) { PathUtil::RemoveExtension(moduleName); PathUtil::MakeGamePath(folderName); // initial load: creates module, registers nodes CFlowGraphModule* pModule = PreLoadModuleFile(moduleName.c_str(), PathUtil::GetPath(folderName)+fd.name, bGlobal); // important: the module should be added using its internal name rather than the filename m_ModulesPathInfo.insert(TModulesPathInfo::value_type(pModule->GetName(), PathUtil::GetPath(folderName)+fd.name)); } } } while (pPak->FindNext(handle, &fd) >= 0); pPak->FindClose(handle); } }
void ScanFolder(std::vector<std::wstring>& files, std::vector<std::wstring>& filters, bool bSubfolders, const std::wstring& path) { // Get folder listing WIN32_FIND_DATA fileData; // Data structure describes the file found HANDLE hSearch; // Search handle returned by FindFirstFile std::wstring searchPath = path + L"*"; hSearch = FindFirstFile(searchPath.c_str(), &fileData); do { if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (bSubfolders && wcscmp(fileData.cFileName, L".") != 0 && wcscmp(fileData.cFileName, L"..") != 0) { ScanFolder(files, filters, bSubfolders, path + fileData.cFileName + L"\\"); } } else { if (!filters.empty()) { for (int i = 0; i < filters.size(); ++i) { if (!filters[i].empty() && PathMatchSpec(fileData.cFileName, filters[i].c_str())) { files.push_back(path + fileData.cFileName); break; } } } else { files.push_back(path + fileData.cFileName); } } } while (FindNextFile(hSearch, &fileData)); }
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue) { MeasureData* measure = (MeasureData*)data; measure->pathname = RmReadPath(rm, L"PathName", L""); if (PathIsDirectory(measure->pathname.c_str())) { std::vector<std::wstring> fileFilters; LPCWSTR filter = RmReadString(rm, L"FileFilter", L""); if (*filter) { std::wstring ext = filter; size_t start = 0; size_t pos = ext.find(L';'); while (pos != std::wstring::npos) { fileFilters.push_back(ext.substr(start, pos - start)); start = pos + 1; pos = ext.find(L';', pos + 1); } fileFilters.push_back(ext.substr(start)); } if (measure->pathname[measure->pathname.size() - 1] != L'\\') { measure->pathname += L"\\"; } // Scan files measure->files.clear(); bool bSubfolders = RmReadInt(rm, L"Subfolders", 1) == 1; ScanFolder(measure->files, fileFilters, bSubfolders, measure->pathname); } else { measure->separator = RmReadString(rm, L"Separator", L"\n"); } srand((unsigned)time(NULL)); }
void DVBMediaAddon::ScanFolder(const char *path) { BDirectory dir(path); if (dir.InitCheck() != B_OK) return; BEntry ent; while (dir.GetNextEntry(&ent) == B_OK) { BPath path(&ent); if (ent.IsDirectory()) { ScanFolder(path.Path()); } else { DVBCard *card = new DVBCard(path.Path()); if (card->InitCheck() == B_OK) AddDevice(card, path.Path()); else delete card; } } }
static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const TCHAR *tszBaseUrl, SERVLIST& hashes, OBJLIST<FILEINFO> *UpdateFiles) { // skip updater's own folder if (!_tcsicmp(tszFolder, tszRoot)) return 0; // skip profile folder TCHAR tszProfilePath[MAX_PATH]; CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszProfilePath), (LPARAM)tszProfilePath); if (!_tcsicmp(tszFolder, tszProfilePath)) return 0; TCHAR tszBuf[MAX_PATH]; mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\*"), tszFolder); WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(tszBuf, &ffd); if (hFind == INVALID_HANDLE_VALUE) return 0; Netlib_LogfT(hNetlibUser,_T("Scanning folder %s"), tszFolder); int count = 0; do { if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { // Scan recursively all subfolders if (_tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T(".."))) { mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName); count += ScanFolder(tszBuf, cbBaseLen, level + 1, tszBaseUrl, hashes, UpdateFiles); } } else if (isValidExtension(ffd.cFileName)) { // calculate the current file's relative name and store it into tszNewName TCHAR tszNewName[MAX_PATH]; if (!CheckFileRename(ffd.cFileName, tszNewName)) { if (level == 0) _tcsncpy(tszNewName, ffd.cFileName, MAX_PATH); else mir_sntprintf(tszNewName, SIZEOF(tszNewName), _T("%s\\%s"), tszFolder + cbBaseLen, ffd.cFileName); } TCHAR *ptszUrl; int MyCRC = 0; mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName); bool bDeleteOnly = (tszNewName[0] == 0); // this file is not marked for deletion if (!bDeleteOnly) { TCHAR *pName = tszNewName; ServListEntry *item = hashes.find((ServListEntry*)&pName); // Not in list? Check for trailing 'W' or 'w' if (item == NULL) { TCHAR *p = _tcsrchr(tszNewName, '.'); if (p[-1] != 'w' && p[-1] != 'W') continue; // remove trailing w or W and try again int iPos = int(p - tszNewName) - 1; strdel(p - 1, 1); if ((item = hashes.find((ServListEntry*)&pName)) == NULL) continue; strdel(tszNewName + iPos, 1); } ptszUrl = item->m_name; // No need to hash a file if we are forcing a redownload anyway if (!opts.bForceRedownload) { // try to hash the file char szMyHash[33]; __try { CalculateModuleHash(tszBuf, szMyHash); // hashes are the same, skipping if (strcmp(szMyHash, item->m_szHash) == 0) continue; } __except (EXCEPTION_EXECUTE_HANDLER) { // smth went wrong, reload a file from scratch } } MyCRC = item->m_crc; }
DVBMediaAddon::DVBMediaAddon(image_id id) : BMediaAddOn(id) { ScanFolder("/dev/dvb"); }
void SelectPackageDlg::Load() { if(selectvars && !base.IsCursor()) return; if(loading) { // If we are called recursively from ProcessEvents, stop current loading and change loadi loadi++; loading = false; return; } int current_loadi = -1; while(current_loadi != loadi) { current_loadi = loadi; if(selectvars) { String assembly = (String)base.Get(0); list.Enable(base.IsCursor()); if(!base.IsCursor()) return; LoadVars(assembly); } Vector<String> upp = GetUppDirs(); packages.Clear(); description.Hide(); progress.Show(); loading = true; data.Clear(); Index<String> dir_exists; String cache_path = CachePath(GetVarsName()); LoadFromFile(data, cache_path); data.SetCount(upp.GetCount()); for(int i = 0; i < upp.GetCount(); i++) // Scan nest folders for subfolders (package candidates) ScanFolder(upp[i], data[i], GetFileName(upp[i]), dir_exists, Null); int update = msecs(); for(int i = 0; i < data.GetCount() && loading; i++) { // Now investigate individual sub folders ArrayMap<String, PkData>& nest = data[i]; for(int i = 0; i < nest.GetCount() && loading; i++) { if(msecs(update) >= 100) { // each 100 ms update the list (and open select dialog after splash screen is closed) if(!IsSplashOpen() && !IsOpen()) Open(); progress++; SyncList(); update = msecs(); } ProcessEvents(); // keep GUI running PkData& d = nest[i]; String path = nest.GetKey(i); FindFile ff(path); if(ff && ff.IsFolder()) { String upp_path = AppendFileName(path, GetFileName(d.package) + ".upp"); LSLOW(); Time tm = FileGetTime(upp_path); if(IsNull(tm)) // .upp file does not exist - not a package d.ispackage = false; else if(tm != d.tm) { // cached info is outdated Package p; if(p.Load(upp_path)) { d.description = p.description; d.main = p.config.GetCount(); d.tm = tm; d.ispackage = true; } else d.ispackage = false; } else d.ispackage = true; if(d.ispackage) { String icon_path = AppendFileName(path, "icon16x16.png"); tm = FileGetTime(icon_path); if(IsNull(tm)) // package icon does not exist d.icon = Null; else if(tm != d.itm) { // chached package icon outdated d.icon = StreamRaster::LoadFileAny(icon_path); d.itm = tm; } } } else nest.Unlink(i); // cached folder was deleted ScanFolder(path, nest, d.nest, dir_exists, d.package + '/'); } nest.Sweep(); } StoreToFile(data, cache_path); progress.Hide(); while(IsSplashOpen()) ProcessEvents(); if(!IsOpen()) Open(); description.Show(); if(loading) { loading = false; SyncList(); } } }
void CacheMonitorServer::ScanFolder(const fs::path & folder) { CacheManager * cache = Factory::GetCacheManager(); fs::path folderMeta = Factory::GetMetaFolder() / Factory::GetService(); try { fs::directory_iterator end; for ( fs::directory_iterator i(folder); i != end; ++ i ) { if ( fs::is_directory(i->status()) ) { ScanFolder(i->path()); } else { struct stat stat; if ( 0 != ::stat(i->path().string().c_str(),&stat) ) { continue; } ExtendedAttribute ea(i->path()); unsigned long long number; int valuesize; if ( ! ea.GetValue( Inode::ATTRIBUTE_NUMBER, &number, sizeof(number), valuesize ) ) { continue; } long state; if ( ! ea.GetValue( Inode::ATTRIBUTE_STATE, &state, sizeof(state), valuesize) ) { continue; } if ( state != Inode::StateBegin ) { continue; } long long size = 0; if ( ! ea.GetValue( Inode::ATTRIBUTE_SIZE, &size, sizeof(size), valuesize) ) { continue; } if ( size <= 0 ) { continue; } if ( ! cache->ExistFile(number) ) { continue; } vector<FileInfo> files; FileMap::iterator iter = files_.insert( FileMap::value_type(stat.st_atime,files) ).first; FileInfo file; file.service = Factory::GetService(); file.path = i->path().string().substr( folderMeta.string().size() ); iter->second.push_back(file); } } } catch ( const boost::filesystem::filesystem_error& e ) { LogError(e.what()); } catch ( const std::exception & e ) { LogError(e.what()); } }
void CacheMonitorServer::ServerThread() { static int waitTime = Factory::GetConfigure()->GetValueSize( Configure::CachePurgeWaitTime ); while ( run_ ) { boost::this_thread::sleep(boost::posix_time::seconds(waitTime)); #ifdef MORE_TEST #else TapeLibraryMgr * mgr = TapeLibraryMgr::Instance(); SystemHwMode mode = mgr->GetSystemHwMode(); if ( mode == SYSTEM_HW_NEED_DIAGNOSE ) { continue; } if ( mode == SYSTEM_HW_DIAGNOSING ) { continue; } int action; if ( mgr->GetWriteCacheAction(action) ) { if ( ! mgr->SetWriteCacheAction(action) ) { LogError("Failure to set write cache action: " << action); } } else { LogError("Failure to get write cache action"); } #endif if ( ! fs::exists(folderMeta_) || ! fs::is_directory(folderMeta_) ) { LogWarn(folderMeta_); continue; } if ( CheckFreeSize(minFreeSize_) ) { continue; } LogInfo(folderMeta_); fs::directory_iterator end; for ( fs::directory_iterator i(folderMeta_); i != end; ++ i ) { if ( ! fs::is_directory(i->status()) ) { continue; } string service = i->path().filename().string(); Factory::SetService(service); Factory::CreateCacheManager(); ScanFolder(i->path()); Factory::ReleaseCacheManager(); Factory::SetService(""); } for ( FileMap::iterator i = files_.begin(); i != files_.end(); ++ i ) { if ( CheckFreeSize(maxFreeSize_) ) { break; } for ( vector<FileInfo>::iterator iter = i->second.begin(); iter != i->second.end(); ++ iter ) { if ( CheckFreeSize(maxFreeSize_) ) { break; } ReleaseFile(*iter); } } files_.clear(); } }