mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 19:22:22 +01:00
decoupled business logic from ui
This commit is contained in:
@@ -32,26 +32,33 @@ Future<String?> openFilePicker(String extension) async {
|
||||
return result.files.first.path;
|
||||
}
|
||||
|
||||
Future<List<Directory>> scanInstallations(String input) => Directory(input)
|
||||
.list(recursive: true)
|
||||
.handleError((_) {}, test: (e) => e is FileSystemException)
|
||||
.where((element) => path.basename(element.path) == "FortniteClient-Win64-Shipping.exe")
|
||||
.map((element) => findContainer(File(element.path)))
|
||||
.where((element) => element != null)
|
||||
.map((element) => element!)
|
||||
.toList();
|
||||
|
||||
Directory? findContainer(File file){
|
||||
var last = file.parent;
|
||||
for(var x = 0; x < 5; x++){
|
||||
var name = path.basename(last.path);
|
||||
if(name != "FortniteGame" || name == "Fortnite"){
|
||||
last = last.parent;
|
||||
continue;
|
||||
}
|
||||
|
||||
return last.parent;
|
||||
Future<File> loadBinary(String binary, bool safe) async{
|
||||
var safeBinary = File("$safeBinariesDirectory\\$binary");
|
||||
if(await safeBinary.exists()){
|
||||
return safeBinary;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
var internal = _locateInternalBinary(binary);
|
||||
if(!safe){
|
||||
return internal;
|
||||
}
|
||||
|
||||
if(await internal.exists()){
|
||||
await internal.copy(safeBinary.path);
|
||||
}
|
||||
|
||||
return safeBinary;
|
||||
}
|
||||
|
||||
File _locateInternalBinary(String binary){
|
||||
return File("$internalBinariesDirectory\\$binary");
|
||||
}
|
||||
|
||||
String get internalBinariesDirectory =>
|
||||
"${File(Platform.resolvedExecutable).parent.path}\\data\\flutter_assets\\assets\\binaries";
|
||||
|
||||
Directory get tempDirectory =>
|
||||
Directory("${Platform.environment["Temp"]}");
|
||||
|
||||
String get safeBinariesDirectory =>
|
||||
"${Platform.environment["UserProfile"]}\\.reboot_launcher";
|
||||
Reference in New Issue
Block a user