@@ -68,6 +68,26 @@ import { getInstallers, getGameInfo as getZoomLibraryGameInfo, refreshInstalled,
6868
6969import type LogWriter from 'backend/logger/log_writer'
7070
71+ async function findDosboxExecutable ( dir : string ) : Promise < string | undefined > {
72+ try {
73+ const list = await fs . promises . readdir ( dir , { withFileTypes : true } )
74+ for ( const file of list ) {
75+ const fullPath = join ( dir , file . name )
76+ if ( file . isDirectory ( ) ) {
77+ const result = await findDosboxExecutable ( fullPath )
78+ if ( result ) {
79+ return result
80+ }
81+ } else if ( file . name . toLowerCase ( ) === 'dosbox.exe' ) {
82+ return fullPath
83+ }
84+ }
85+ } catch ( error ) {
86+ logError ( `Error finding dosbox.exe in ${ dir } : ${ error } ` , LogPrefix . Zoom )
87+ }
88+ return undefined
89+ }
90+
7191export async function getExtraInfo ( ) : Promise < ExtraInfo > {
7292 // Zoom.py doesn't have direct equivalents for reqs, changelog, etc.
7393 // This part would need to be implemented if the Zoom API provides such data.
@@ -301,23 +321,24 @@ export async function install(
301321 let finalExecutable = ''
302322
303323 if ( installPlatform === 'windows' ) {
304- logInfo ( `Searching for executable in ${ path } !!!!` , LogPrefix . Zoom )
305- const files = await fs . promises . readdir ( path , { withFileTypes : true } )
324+ const installPath = join ( path , gameInfo . folder_name )
325+ logInfo ( `Searching for executable in ${ installPath } !!!!` , LogPrefix . Zoom )
326+ const files = await fs . promises . readdir ( installPath , { withFileTypes : true } )
306327 const confFiles = files
307328 . filter ( f => f . isFile ( ) && f . name . endsWith ( '.conf' ) )
308329 . map ( f => f . name )
309330
310331 if ( confFiles . length > 0 ) {
311- const dosboxExe = files . find ( f => f . isFile ( ) && f . name . toLowerCase ( ) === 'dosbox.exe' )
312- if ( dosboxExe ) {
313- finalExecutable = dosboxExe . name
332+ const dosboxExePath = await findDosboxExecutable ( installPath )
333+ if ( dosboxExePath ) {
334+ finalExecutable = relative ( installPath , dosboxExePath )
314335 isDosbox = true
315336 dosboxConf = confFiles [ 0 ] // Assume the first .conf file is the correct one
316337 }
317338 }
318339
319340 if ( ! isDosbox ) {
320- const files = await fs . promises . readdir ( path , { withFileTypes : true } )
341+ const files = await fs . promises . readdir ( installPath , { withFileTypes : true } )
321342 const exes = files
322343 . filter ( f => f . isFile ( ) && f . name . endsWith ( '.exe' ) )
323344 . map ( f => f . name )
@@ -336,7 +357,7 @@ export async function install(
336357 // As a fallback, pick the largest exe
337358 let largestSize = 0
338359 for ( const exe of exes ) {
339- const exePath = join ( path , exe )
360+ const exePath = join ( installPath , exe )
340361 const stats = fs . statSync ( exePath )
341362 if ( stats . size > largestSize ) {
342363 largestSize = stats . size
0 commit comments