리펙토링

This commit is contained in:
leedongmyung[desktop] 2023-11-05 19:17:08 +09:00
parent 264bf46387
commit 2f0d628130
2 changed files with 13 additions and 19 deletions

View file

@ -6,9 +6,9 @@ import 'dart:typed_data';
import 'package:yaml/yaml.dart';
import 'package:path/path.dart' as path;
late Future<String> Function() getUserPath;
late Future<String> Function() getProjectName;
late Future<String> Function() getDataPath;
late String Function() getUserPath;
late String Function() getProjectName;
late String Function() getDataPath;
void initialize() {
getUserPath = getUserPath_;
@ -115,8 +115,7 @@ Future<Uint8List?> readFileByte(String filePath) async {
return c.future;
}
Future<String> getUserPath_() async {
var c = Completer<String>();
String getUserPath_() {
String home = '';
Map<String, String> envVars = Platform.environment;
if (Platform.isMacOS) {
@ -126,32 +125,27 @@ Future<String> getUserPath_() async {
} else if (Platform.isWindows) {
home = envVars['UserProfile']!;
}
c.complete(home);
return c.future;
return home;
}
Future<String> getDataPath_() async {
var c = Completer<String>();
String path = await getUserPath();
String getDataPath_() {
String path = getUserPath();
if (Platform.isMacOS) {
path = '$path/Library/Application Support/${await getProjectName()}';
path = '$path/Library/Application Support/${getProjectName()}';
} else if (Platform.isLinux) {
path = '$path/.config/${await getProjectName()}';
path = '$path/.config/${getProjectName()}';
} else if (Platform.isWindows) {
path = '$path/AppData/Local/${await getProjectName()}';
path = '$path/AppData/Local/${getProjectName()}';
}
c.complete(path);
return c.future;
return path;
}
Future<String> getProjectName_() async {
var c = Completer<String>();
String getProjectName_() {
var name =
path.dirname(Platform.script.toFilePath(windows: Platform.isWindows));
print(name);
if (path.basename(name) == 'bin') {
name = path.dirname(name);
}
c.complete(path.basename(name));
return c.future;
return path.basename(name);
}