* Replaces an Application Path from the metadata with one appropriate for the operating system. * * @param filePath Application Path as provided in the metadata * @param execMappings Mappings of execs from execs.json * @param native Use application native to the users operating syste
(filePath: string, execMappings: ExecMapping[], native: boolean)
| 312 | * @param native Use application native to the users operating system, if possible |
| 313 | */ |
| 314 | function getApplicationPath(filePath: string, execMappings: ExecMapping[], native: boolean): string { |
| 315 | const platform = process.platform; |
| 316 | |
| 317 | // Bat files won't work on Wine, force a .sh file on non-Windows platforms instead. Sh File may not exist. |
| 318 | if (platform !== 'win32' && filePath.endsWith('.bat')) { |
| 319 | return filePath.substring(0, filePath.length - 4) + '.sh'; |
| 320 | } |
| 321 | |
| 322 | // Skip mapping if on Windows |
| 323 | if (platform !== 'win32') { |
| 324 | for (let i = 0; i < execMappings.length; i++) { |
| 325 | const mapping = execMappings[i]; |
| 326 | if (mapping.win32 === filePath) { |
| 327 | switch (platform) { |
| 328 | case 'linux': |
| 329 | // If we are trying to run this game natively: |
| 330 | if (native) { |
| 331 | // Use the native binary (if configured.) |
| 332 | return mapping.linux || mapping.win32; |
| 333 | } else { |
| 334 | // Otherwise, use the wine binary (if configured.) |
| 335 | return mapping.wine || mapping.win32; |
| 336 | } |
| 337 | case 'darwin': |
| 338 | // If we are trying to run this game natively: |
| 339 | if (native) { |
| 340 | // Use the native binary (if configured.) |
| 341 | return mapping.darwin || mapping.win32; |
| 342 | } else { |
| 343 | // Otherwise, use the wine binary (if configured.) |
| 344 | return mapping.darwine || mapping.win32; |
| 345 | } |
| 346 | default: |
| 347 | return filePath; |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | // No Native exec found, return Windows/XML application path |
| 354 | return filePath; |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * Get an object containing the environment variables to use for the game / additional application. |
no outgoing calls
no test coverage detected