mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-27 14:09:50 +00:00
f16a86cdfe
since other builds could have worked and have already wallet files in the documents folder
33 lines
878 B
Dart
33 lines
878 B
Dart
import 'dart:io';
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
String? _rootDirPath;
|
|
|
|
void setRootDirFromEnv() => _rootDirPath = Platform.environment['CAKE_WALLET_DIR'];
|
|
|
|
Future<Directory> getAppDir({String appName = 'cake_wallet'}) async {
|
|
Directory dir;
|
|
|
|
if (_rootDirPath != null && _rootDirPath!.isNotEmpty) {
|
|
dir = Directory.fromUri(Uri.file(_rootDirPath!));
|
|
dir.create(recursive: true);
|
|
} else {
|
|
if (Platform.isLinux) {
|
|
String appDirPath;
|
|
|
|
try {
|
|
dir = await getApplicationDocumentsDirectory();
|
|
appDirPath = '${dir.path}/$appName';
|
|
} catch (e) {
|
|
appDirPath = '/home/${Platform.environment['USER']}/.$appName';
|
|
}
|
|
|
|
dir = Directory.fromUri(Uri.file(appDirPath));
|
|
await dir.create(recursive: true);
|
|
} else {
|
|
dir = await getApplicationDocumentsDirectory();
|
|
}
|
|
}
|
|
|
|
return dir;
|
|
}
|