Package mekhq.campaign.io
Class CampaignSaveBackup
java.lang.Object
mekhq.campaign.io.CampaignSaveBackup
Copies a campaign save before it is upgraded, so the player can return to it if the upgrade goes wrong.
The copy sits next to the save and keeps its extension, so it still appears in the list of campaigns to load.
Its name records the version it came from, for example Kestrel's Lancers (backup from 0.50.11).cpnx.gz.
An existing file is never overwritten; a number is added instead.
- Since:
- 0.51.01
-
Method Summary
Modifier and TypeMethodDescriptionstatic FilebackupFileFor(File save, megamek.Version fromVersion) Picks a free file name for a backup of a save.static FilecreateBackup(File save, megamek.Version fromVersion) Copies a save to a new backup file next to it.
-
Method Details
-
backupFileFor
Picks a free file name for a backup of a save.- Parameters:
save- the save to back upfromVersion- the version the save was made in- Returns:
- a file next to the save that does not exist yet
- Throws:
IOException- if no free name could be found
-
createBackup
Copies a save to a new backup file next to it.- Parameters:
save- the save to back upfromVersion- the version the save was made in- Returns:
- the backup file
- Throws:
IOException- if the save can't be read or the copy can't be written
-