String basename = filename;
String extension = "";
int dotcharpos = filename.lastIndexOf('.');
- // don't split of filenames with the last '.' at the very beginning or
+ // don't split filenames with the last '.' at the very beginning or
// very end of the filename
if ((dotcharpos > 0) && (dotcharpos < filename.length() - 1))
{
}
else
{
-
- // sort the backup files (based on integer found in the suffix) using a
- // precomputed Hashmap for speed
- Map<Integer, File> bfHashMap = new HashMap<>();
- for (int i = 0; i < backupFiles.length; i++)
- {
- File f = backupFiles[i];
- BackupFilenameParts bfp = new BackupFilenameParts(f, basename, suffix, digits, extension);
- bfHashMap.put(bfp.indexNum(), f);
- }
- TreeMap<Integer, File> bfTreeMap = new TreeMap<>();
- bfTreeMap.putAll(bfHashMap);
+ TreeMap<Integer, File> bfTreeMap = sortBackupFilesAsTreeMap(backupFiles, basename, extension);
if (reverseOrder)
{
}
}
+ deleteOldFiles(oldFilesToDelete, confirmDeleteExtraInfo);
+
+ // Let's make the new backup file!! yay, got there at last!
+ String latestBackupFilename = dir + File.separatorChar
+ + BackupFilenameFilter.getBackupFilename(nextIndexNum, basename,
+ suffix, digits, extension);
+ File latestBackupFile = new File(latestBackupFilename);
+ ret = ret && file.renameTo(latestBackupFile);
+
+ return ret;
+ }
+
+ private void deleteOldFiles(File[] oldFilesToDelete, String confirmDeleteExtraInfo) {
if (oldFilesToDelete != null && oldFilesToDelete.length > 0)
{
// delete old backup/version files
}
}
+ }
- // Let's make the new backup file!! yay, got there at last!
- String latestBackupFilename = dir + File.separatorChar
- + BackupFilenameFilter.getBackupFilename(nextIndexNum, basename,
- suffix, digits, extension);
- File latestBackupFile = new File(latestBackupFilename);
- ret = ret && file.renameTo(latestBackupFile);
-
- return ret;
+ private TreeMap sortBackupFilesAsTreeMap(File[] backupFiles, String basename, String extension) {
+ // sort the backup files (based on integer found in the suffix) using a
+ // precomputed Hashmap for speed
+ Map<Integer, File> bfHashMap = new HashMap<>();
+ for (int i = 0; i < backupFiles.length; i++)
+ {
+ File f = backupFiles[i];
+ BackupFilenameParts bfp = new BackupFilenameParts(f, basename, suffix, digits, extension);
+ bfHashMap.put(bfp.indexNum(), f);
+ }
+ TreeMap<Integer, File> bfTreeMap = new TreeMap<>();
+ bfTreeMap.putAll(bfHashMap);
+ return bfTreeMap;
}
public boolean rollBackupsAndRenameTempFile()