mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 11:12:23 +01:00
64 lines
1.6 KiB
Dart
64 lines
1.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:file_picker/file_picker.dart';
|
|
import 'package:path/path.dart' as path;
|
|
|
|
const int appBarSize = 2;
|
|
final RegExp _regex = RegExp(r'(?<=\(Build )(.*)(?=\))');
|
|
|
|
bool get isWin11 {
|
|
var result = _regex.firstMatch(Platform.operatingSystemVersion)?.group(1);
|
|
if(result == null){
|
|
return false;
|
|
}
|
|
|
|
var intBuild = int.tryParse(result);
|
|
return intBuild != null && intBuild > 22000;
|
|
}
|
|
|
|
Future<String?> openFolderPicker(String title) async =>
|
|
await FilePicker.platform.getDirectoryPath(dialogTitle: title);
|
|
|
|
Future<String?> openFilePicker(String extension) async {
|
|
var result = await FilePicker.platform.pickFiles(
|
|
type: FileType.custom,
|
|
allowMultiple: false,
|
|
allowedExtensions: [extension]
|
|
);
|
|
if(result == null || result.files.isEmpty){
|
|
return null;
|
|
}
|
|
|
|
return result.files.first.path;
|
|
}
|
|
|
|
Future<File> loadBinary(String binary, bool safe) async{
|
|
var safeBinary = File("$safeBinariesDirectory\\$binary");
|
|
if(await safeBinary.exists()){
|
|
return safeBinary;
|
|
}
|
|
|
|
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"; |