From 2f0d628130dd28576a949a2b97b7e476bff3da51 Mon Sep 17 00:00:00 2001 From: "leedongmyung[desktop]" Date: Sun, 5 Nov 2023 19:17:08 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/utils/system_util.dart | 32 ++++++++------------ test/{dart_framework_test.dart => test.dart} | 0 2 files changed, 13 insertions(+), 19 deletions(-) rename test/{dart_framework_test.dart => test.dart} (100%) 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