mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-26 20:46:21 +00:00
24 lines
757 B
Dart
24 lines
757 B
Dart
|
import 'dart:io';
|
||
|
|
||
|
import 'package:path_provider/path_provider.dart';
|
||
|
|
||
|
class Checkpoints {
|
||
|
static const String _baseDirSuffix = '/checkpoints';
|
||
|
|
||
|
static void createCheckpoint(String checkpointId) async {
|
||
|
final appDocDir = await getApplicationDocumentsDirectory();
|
||
|
final file = File('${appDocDir.path}$_baseDirSuffix/${checkpointId}_${DateTime.now()}');
|
||
|
|
||
|
file.create(recursive: true);
|
||
|
}
|
||
|
|
||
|
static Future<Iterable<String>> getCheckpoints() async {
|
||
|
final appDocDir = await getApplicationDocumentsDirectory();
|
||
|
final checkpointsDir = Directory('${appDocDir.path}$_baseDirSuffix');
|
||
|
|
||
|
if (!checkpointsDir.existsSync()) return ["No checkpoints available"];
|
||
|
|
||
|
return checkpointsDir.listSync().map((e) => e.path.split('/').last);
|
||
|
}
|
||
|
}
|