Implemented basic save backups

This commit is contained in:
Anuken 2018-01-02 21:05:44 -05:00
parent 3a46146055
commit d12f78f6ce

View File

@ -25,7 +25,14 @@ public class SaveIO{
Settings.putString("save-"+slot+"-data", new String(Base64Coder.encode(stream.toByteArray())));
Settings.save();
}else{
write(fileFor(slot));
FileHandle file = fileFor(slot);
file.moveTo(file.sibling(file.name() + "-backup." + file.extension()));
try {
write(fileFor(slot));
}catch (Exception e){
file.sibling(file.name() + "-backup." + file.extension()).moveTo(file);
throw new RuntimeException(e);
}
}
}