mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 20:29:57 +00:00
allow setting custom app root dir on desktop via cli args
This commit is contained in:
parent
2811063699
commit
09a452b4ca
2 changed files with 24 additions and 5 deletions
|
@ -81,9 +81,13 @@ final openedFromSWBFileStringStateProvider =
|
|||
// main() is the entry point to the app. It initializes Hive (local database),
|
||||
// runs the MyApp widget and checks for new users, caching the value in the
|
||||
// miscellaneous box for later use
|
||||
void main() async {
|
||||
void main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
if (Util.isDesktop && args.length == 2 && args.first == "-d") {
|
||||
StackFileSystem.overrideDir = args.last;
|
||||
}
|
||||
|
||||
final loadCoinlibFuture = loadCoinlib();
|
||||
|
||||
GoogleFonts.config.allowRuntimeFetching = false;
|
||||
|
|
|
@ -15,6 +15,8 @@ import 'package:stackwallet/utilities/logger.dart';
|
|||
import 'package:stackwallet/utilities/util.dart';
|
||||
|
||||
abstract class StackFileSystem {
|
||||
static String? overrideDir;
|
||||
|
||||
static Future<Directory> applicationRootDirectory() async {
|
||||
Directory appDirectory;
|
||||
|
||||
|
@ -23,12 +25,25 @@ abstract class StackFileSystem {
|
|||
appDirectory = await getApplicationDocumentsDirectory();
|
||||
appDirectory = Directory("${appDirectory.path}/.stackwallet");
|
||||
} else if (Platform.isLinux) {
|
||||
appDirectory = Directory("${Platform.environment['HOME']}/.stackwallet");
|
||||
if (overrideDir != null) {
|
||||
appDirectory = Directory(overrideDir!);
|
||||
} else {
|
||||
appDirectory =
|
||||
Directory("${Platform.environment['HOME']}/.stackwallet");
|
||||
}
|
||||
} else if (Platform.isWindows) {
|
||||
if (overrideDir != null) {
|
||||
appDirectory = Directory(overrideDir!);
|
||||
} else {
|
||||
appDirectory = await getApplicationSupportDirectory();
|
||||
}
|
||||
} else if (Platform.isMacOS) {
|
||||
if (overrideDir != null) {
|
||||
appDirectory = Directory(overrideDir!);
|
||||
} else {
|
||||
appDirectory = await getLibraryDirectory();
|
||||
appDirectory = Directory("${appDirectory.path}/stackwallet");
|
||||
}
|
||||
} else if (Platform.isIOS) {
|
||||
// todo: check if we need different behaviour here
|
||||
if (Util.isDesktop) {
|
||||
|
|
Loading…
Reference in a new issue