bool SSH::findInstallation() { auto env = new Environment(); SubutaiLauncher::SubutaiString pathVar(env->getVar("PATH", "")); std::vector<std::string> path; pathVar.split(':', path); FileSystem fs; for (auto it = path.begin(); it != path.end(); it++) { fs.setPath((*it)); if (fs.isFileExists(BIN)) { _installed = true; _path = (*it); _location = _path; _path.append(FileSystem::DELIM); _path.append(BIN); return true; } } return false; }
int main( int argc, char *argv[] ) { // Init controller db file for backend Q_INIT_RESOURCE( controllerdb ); // Uncomment this to enable the message handler for debugging and stack tracing // qInstallMessageHandler( phoenixDebugMessageHandler ); // Handles stuff with the windowing system QGuiApplication app( argc, argv ); // The engine that runs our QML-based UI QQmlApplicationEngine engine; // Set application metadata QGuiApplication::setApplicationDisplayName( QStringLiteral( "Phoenix" ) ); QGuiApplication::setApplicationName( QStringLiteral( "Phoenix" ) ); QGuiApplication::setApplicationVersion( QStringLiteral( "0.0.1" ) ); QGuiApplication::setOrganizationName( QStringLiteral( "Team Phoenix" ) ); QGuiApplication::setOrganizationDomain( QStringLiteral( "phoenix.vg" ) ); // Figure out the right paths for the environment, and create user storage folders if not already there Library::PhxPaths::initPaths(); // For release builds, write to a log file along with the console #ifdef QT_NO_DEBUG QFile logFile( Library::PhxPaths::userDataLocation() % '/' % QStringLiteral( "Logs" ) % '/' % QDateTime::currentDateTime().toString( QStringLiteral( "ddd MMM d yyyy - h mm ss AP" ) ) % QStringLiteral( ".log" ) ); // If this fails... how would we know? :) logFile.open( QIODevice::WriteOnly | QIODevice::Text ); int logFD = logFile.handle(); logFP = fdopen( dup( logFD ), "w" ); qInstallMessageHandler( phoenixDebugMessageLog ); #endif // Open connections to the SQL databases. Library::LibretroDatabase::open(); Library::MetaDataDatabase::open(); // Necessary to quit properly QObject::connect( &engine, &QQmlApplicationEngine::quit, &app, &QGuiApplication::quit ); // Register our custom types for use within QML VideoItem::registerTypes(); InputManager::registerTypes(); // Register our custom QML-accessable/instantiable objects qmlRegisterType<Library::PlatformsModel>( "vg.phoenix.models", 1, 0, "PlatformsModel" ); qmlRegisterType<Library::CollectionsModel>( "vg.phoenix.models", 1, 0, "CollectionsModel" ); qmlRegisterType<Library::LibraryModel>( "vg.phoenix.models", 1, 0, "LibraryModel" ); qmlRegisterType<Library::CoreModel>( "vg.phoenix.models", 1, 0, "CoreModel" ); qmlRegisterType<Library::ImageCacher>( "vg.phoenix.cache", 1, 0, "ImageCacher" ); qmlRegisterType<GameLauncher>( "vg.phoenix.launcher", 1, 0, "GameLauncher" ); // Register our custom QML-accessable objects and instantiate them here qmlRegisterSingletonType( QUrl( "qrc:/PhxTheme.qml" ), "vg.phoenix.themes", 1, 0, "PhxTheme" ); qmlRegisterSingletonType<Library::PhxPaths>( "vg.phoenix.paths", 1, 0, "PhxPaths", PhxPathsSingletonProviderCallback ); qRegisterMetaType<Library::GameData>( "GameData" ); // Load the root QML object and everything under it engine.load( QUrl( QStringLiteral( "qrc:/main.qml" ) ) ); // Ensure custom controller DB file exists QFile gameControllerDBFile( Library::PhxPaths::userDataLocation() % '/' % QStringLiteral( "gamecontrollerdb.txt" ) ); if( !gameControllerDBFile.exists() ) { gameControllerDBFile.open( QIODevice::ReadWrite ); QTextStream stream( &gameControllerDBFile ); stream << "# Insert your custom definitions here" << endl; gameControllerDBFile.close(); } // Set InputManager's custom controller DB file QQmlProperty prop( engine.rootObjects().first(), "inputManager.controllerDBFile" ); Q_ASSERT( prop.isValid() ); QString path = Library::PhxPaths::userDataLocation() % QStringLiteral( "/gamecontrollerdb.txt" ); QVariant pathVar( path ); prop.write( pathVar ); // Run the app and write return code to the log file if in release mode #ifdef QT_NO_DEBUG int ret = app.exec(); fprintf( logFP, "Returned %d", ret ); fclose( logFP ); return ret; #else // Otherwise, just run it normally return app.exec(); #endif }