2020-05-12 12:04:54 +00:00
|
|
|
import 'dart:io';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/wallet_type.dart';
|
2020-05-12 12:04:54 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
|
|
|
Future<String> pathForWalletDir({@required String name, @required WalletType type}) async {
|
|
|
|
final root = await getApplicationDocumentsDirectory();
|
|
|
|
final prefix = walletTypeToString(type).toLowerCase();
|
|
|
|
final walletsDir = Directory('${root.path}/wallets');
|
|
|
|
final walletDire = Directory('${walletsDir.path}/$prefix/$name');
|
|
|
|
|
|
|
|
if (!walletDire.existsSync()) {
|
|
|
|
walletDire.createSync(recursive: true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return walletDire.path;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<String> pathForWallet({@required String name, @required WalletType type}) async =>
|
|
|
|
await pathForWalletDir(name: name, type: type)
|
|
|
|
.then((path) => path + '/$name');
|
2020-11-13 14:58:28 +00:00
|
|
|
|
|
|
|
Future<String> outdatedAndroidPathForWalletDir({String name}) async {
|
|
|
|
final directory = await getApplicationDocumentsDirectory();
|
|
|
|
final pathDir = directory.path + '/$name';
|
|
|
|
|
|
|
|
return pathDir;
|
|
|
|
}
|