mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-25 12:06:05 +00:00
23 lines
757 B
Dart
23 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);
|
|
}
|
|
}
|