@@ -606,6 +606,56 @@ void CMainWindow::ShowError( const QString& message, const QString& details )
606606 this ->m_ErrorBoxWidget .SetVisible ( true );
607607}
608608
609+ // Externally commanded to open a path, might be a directory or file
610+ void CMainWindow::OpenPath ( fs::path path )
611+ {
612+ if ( fs::exists ( path ) == false )
613+ {
614+ QString convertedPath = QString::fromStdString ( path.generic_string () );
615+ this ->ShowError ( tr ( " Could not open non-existent path <code>%1</code>." )
616+ .arg ( convertedPath ),
617+ this ->m_Model .GetError () );
618+ return ;
619+ }
620+
621+ path = fs::canonical ( path );
622+
623+ if ( fs::is_directory ( path ) )
624+ {
625+ GameDataInfo detectedGameInfo{};
626+ detectedGameInfo.SetGameDataPath ( path );
627+
628+ if ( detectedGameInfo.WasGameDetected () == false )
629+ {
630+ fs::path path_data = path / " Data" ;
631+ if ( fs::exists ( path_data ) && fs::is_directory ( path_data ) )
632+ {
633+ path = path_data;
634+ detectedGameInfo.SetGameDataPath ( path_data );
635+ }
636+ }
637+
638+ if ( detectedGameInfo.WasGameDetected () == false )
639+ {
640+ QString convertedPath = QString::fromStdString ( path.generic_string () );
641+ this ->ShowError ( tr ( " Could not detect any compatible game in the directory "
642+ " (<code>%1</code>)." ).arg ( convertedPath ),
643+ this ->m_Model .GetError () );
644+ }
645+ else
646+ {
647+ this ->OnIndexFileAccepted ( detectedGameInfo );
648+ }
649+ }
650+ else
651+ {
652+ this ->m_LastOpenDir =
653+ QString::fromStdString ( path.parent_path ().generic_string () );
654+
655+ this ->LoadPackage ( path );
656+ }
657+ }
658+
609659void CMainWindow::OnFileOpen ()
610660{
611661 const fs::path filePath =
0 commit comments