diff --git a/lib/utils/system_util.dart b/lib/utils/system_util.dart index fd0c737..92312a2 100644 --- a/lib/utils/system_util.dart +++ b/lib/utils/system_util.dart @@ -6,9 +6,9 @@ import 'dart:typed_data'; import 'package:yaml/yaml.dart'; import 'package:path/path.dart' as path; -late Future Function() getUserPath; -late Future Function() getProjectName; -late Future Function() getDataPath; +late String Function() getUserPath; +late String Function() getProjectName; +late String Function() getDataPath; void initialize() { getUserPath = getUserPath_; @@ -115,8 +115,7 @@ Future readFileByte(String filePath) async { return c.future; } -Future getUserPath_() async { - var c = Completer(); +String getUserPath_() { String home = ''; Map envVars = Platform.environment; if (Platform.isMacOS) { @@ -126,32 +125,27 @@ Future getUserPath_() async { } else if (Platform.isWindows) { home = envVars['UserProfile']!; } - c.complete(home); - return c.future; + return home; } -Future getDataPath_() async { - var c = Completer(); - 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 getProjectName_() async { - var c = Completer(); +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); } diff --git a/test/dart_framework_test.dart b/test/test.dart similarity index 100% rename from test/dart_framework_test.dart rename to test/test.dart