-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor install finder platform wrapper methods into struct
- Loading branch information
1 parent
12c1450
commit 86f4e9b
Showing
18 changed files
with
196 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package common | ||
|
||
type Platform interface { | ||
ProcessPath(path string) string | ||
Os() string | ||
} | ||
|
||
type LauncherPlatform struct { | ||
Platform | ||
launcherCommand func(arg string) []string | ||
} | ||
|
||
func MakeLauncherPlatform(platform Platform, launcherCommand func(arg string) []string) LauncherPlatform { | ||
return LauncherPlatform{Platform: platform, launcherCommand: launcherCommand} | ||
} | ||
|
||
func (p LauncherPlatform) LauncherCommand(arg string) []string { | ||
if p.launcherCommand != nil { | ||
return p.launcherCommand(arg) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package common | ||
|
||
import ( | ||
"runtime" | ||
) | ||
|
||
type nativePlatform struct{} | ||
|
||
func NativePlatform() Platform { | ||
return nativePlatform{} | ||
} | ||
|
||
func (p nativePlatform) ProcessPath(path string) string { | ||
return path | ||
} | ||
|
||
func (p nativePlatform) Os() string { | ||
return runtime.GOOS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build unix | ||
|
||
package common | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
type winePlatform struct { | ||
winePrefix string | ||
} | ||
|
||
func WineLauncherPlatform(winePrefix string) Platform { | ||
return winePlatform{winePrefix: winePrefix} | ||
} | ||
|
||
func (p winePlatform) ProcessPath(path string) string { | ||
return filepath.Join(p.winePrefix, "dosdevices", strings.ToLower(path[0:1])+strings.ReplaceAll(path[1:], "\\", "/")) | ||
} | ||
|
||
func (p winePlatform) Os() string { | ||
return "windows" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.