Added backup function; if file already exists when saving, renames to .bak

This commit is contained in:
blha303
2013-03-23 15:21:15 +08:00
parent f0edcab99e
commit b784469af2
@@ -127,6 +127,9 @@ public class VaultManager {
*/ */
public void saveFile(String name, YamlConfiguration yaml) throws IOException { public void saveFile(String name, YamlConfiguration yaml) throws IOException {
File file = new File(directory + File.separator + name.toLowerCase() + ".yml"); File file = new File(directory + File.separator + name.toLowerCase() + ".yml");
if (file.exists()) {
file.renameTo(new File(directory + File.separator + name.toLowerCase() + ".yml.bak"));
}
yaml.save(file); yaml.save(file);
} }
} }