Add function to list world snapshot files
This commit is contained in:
parent
b8426e286b
commit
a2737c82f9
1 changed files with 14 additions and 3 deletions
|
@ -162,7 +162,7 @@ class Settings {
|
|||
return PathHelper(pth: base_path).resolve("mods.jail").build();
|
||||
}
|
||||
|
||||
String getWorldSnapshots() {
|
||||
String getWorldSnapshotFolder() {
|
||||
return PathHelper(pth: base_path).resolve("backups").build();
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,17 @@ class Settings {
|
|||
return pth2.build(); // Fallback to game.db
|
||||
}
|
||||
|
||||
Future<List<String>> getWorldSnapshotFiles() async {
|
||||
Directory dir = Directory(getWorldSnapshotFolder());
|
||||
var lst = await dir.list().toList();
|
||||
List<String> backupNames = [];
|
||||
for(var file in lst) {
|
||||
backupNames.add(file.path);
|
||||
}
|
||||
|
||||
return backupNames;
|
||||
}
|
||||
|
||||
Future<void> createModFolderIfNotExists() async {
|
||||
if (Directory(getModPath()).existsSync()) {
|
||||
return;
|
||||
|
@ -194,10 +205,10 @@ class Settings {
|
|||
}
|
||||
|
||||
Future<void> createBackupsFolderIfNotExists() async {
|
||||
if(Directory(getWorldSnapshots()).existsSync()) {
|
||||
if(Directory(getWorldSnapshotFolder()).existsSync()) {
|
||||
return;
|
||||
}else {
|
||||
await Directory(getWorldSnapshots()).create(recursive: true);
|
||||
await Directory(getWorldSnapshotFolder()).create(recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue