static void BuildList( void ) { int numDirs, numDemos; void **dirlist, **demolist; char *cache, *p; unsigned flags; size_t len; int i; // this can be a lengthy process S_StopAllSounds(); m_demos.menu.status = "Building list..."; SCR_UpdateScreen(); // list files flags = ui_listalldemos->integer ? 0 : FS_TYPE_REAL | FS_PATH_GAME; dirlist = FS_ListFiles( m_demos.browse, NULL, flags | FS_SEARCH_DIRSONLY, &numDirs ); demolist = FS_ListFiles( m_demos.browse, DEMO_EXTENSIONS, flags | FS_SEARCH_EXTRAINFO, &numDemos ); // alloc entries m_demos.list.items = UI_Malloc( sizeof( demoEntry_t * ) * ( numDirs + numDemos + 1 ) ); m_demos.list.numItems = 0; m_demos.list.curvalue = 0; m_demos.list.prestep = 0; m_demos.widest_map = 3; m_demos.widest_pov = 3; m_demos.total_bytes = 0; // start with minimum size m_demos.menu.size( &m_demos.menu ); if( m_demos.browse[0] ) { BuildDir( "..", ENTRY_UP ); } // add directories if( dirlist ) { for( i = 0; i < numDirs; i++ ) { BuildDir( dirlist[i], ENTRY_DN ); } FS_FreeList( dirlist ); } m_demos.numDirs = m_demos.list.numItems; // add demos if( demolist ) { CalcHash( demolist ); if( ( cache = LoadCache( demolist ) ) != NULL ) { p = cache + 32 + 1; for( i = 0; i < numDemos; i++ ) { BuildName( demolist[i], &p ); } FS_FreeFile( cache ); } else { for( i = 0; i < numDemos; i++ ) { BuildName( demolist[i], NULL ); if( ( i & 7 ) == 0 ) { m_demos.menu.size( &m_demos.menu ); SCR_UpdateScreen(); } } } WriteCache(); FS_FreeList( demolist ); } // update status line and sort if( m_demos.list.numItems ) { Change( &m_demos.list.generic ); if( m_demos.list.sortdir ) { m_demos.list.sort( &m_demos.list, m_demos.list.sortcol ); } } // resize columns m_demos.menu.size( &m_demos.menu ); // format our extra status line i = m_demos.list.numItems - m_demos.numDirs; len = Q_scnprintf( m_demos.status, sizeof( m_demos.status ), "%d demo%s, ", i, i == 1 ? "" : "s" ); Com_FormatSizeLong( m_demos.status + len, sizeof( m_demos.status ) - len, m_demos.total_bytes ); SCR_UpdateScreen(); }
void WareSrcContainer::configure() { if (m_CMakeProgramPath.isEmpty()) findCMake(); mp_Stream->clear(); m_Messages.clear(); QFile BuildDir(m_BuildDirPath); if (BuildDir.exists()) openfluid::tools::emptyDirectoryRecursively(QString(m_BuildDirPath).toStdString()); else if (!QDir().mkpath(m_BuildDirPath)) throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION, "unable to create build directory"); QString Options = QString(" -DCMAKE_BUILD_TYPE=%1").arg( m_ConfigMode == ConfigMode::CONFIG_RELEASE ? "Release" : "Debug"); // Use OPENFLUID_INSTALL_PREFIX env. var. if defined QByteArray OpenFLUIDInstallPrefix = qgetenv("OPENFLUID_INSTALL_PREFIX"); if (!OpenFLUIDInstallPrefix.isNull()) { Options.prepend(" -DCMAKE_PREFIX_PATH=" + OpenFLUIDInstallPrefix + "/lib/cmake"); } // Use specific options if configured QString ExtraOptions = openfluid::base::PreferencesManager::instance()->getWaresdevConfigOptions(); if (!Options.isEmpty()) { ExtraOptions = " " + ExtraOptions; Options.prepend(ExtraOptions); } // Use specific generator if configured QString Generator = openfluid::base::PreferencesManager::instance()->getWaresdevConfigGenerator(); if (!Generator.isEmpty()) { QString GeneratorOption = QString(" -G \"%1\"").arg(Generator); Options.prepend(GeneratorOption); } QProcessEnvironment RunEnv = QProcessEnvironment::systemEnvironment(); // Set PATH env. var. if configured QString CustomPath = openfluid::base::PreferencesManager::instance()->getWaresdevConfigEnv("PATH"); if (!CustomPath.isEmpty()) { QByteArray ExistingPath = qgetenv("PATH"); if (!ExistingPath.isNull()) { CustomPath.replace("%%PATH%%", ExistingPath); RunEnv.insert("PATH", CustomPath); } } delete mp_CurrentParser; mp_CurrentParser = new openfluid::waresdev::WareSrcMsgParserCMake(m_AbsolutePath); QString Command = QString("\"%1\" -E chdir \"%2\" \"%1\" \"%3\" %4") .arg(m_CMakeProgramPath) .arg(m_BuildDirPath) .arg(m_AbsolutePath) .arg(Options); runCommand(Command, RunEnv); }