import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.TreeMap;
private static final String oldTempFileSuffix = "_oldfile_tobedeleted";
+ private static List<BackupFiles> savesInProgress = new ArrayList<>();
+
+ private boolean addSaveInProgress()
+ {
+ if (savesInProgress.contains(this))
+ {
+ return false;
+ }
+ else
+ {
+ savesInProgress.add(this);
+ return true;
+ }
+ }
+
+ private boolean removeSaveInProgress()
+ {
+ if (savesInProgress.contains(this))
+ {
+ // remove all occurrences
+ while (savesInProgress.remove(this))
+ {
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public static boolean hasSavesInProgress()
+ {
+ return savesInProgress.size() > 0;
+ }
+
+ public static List<File> savesInProgressFiles()
+ {
+ List<File> files = new ArrayList<>();
+ for (BackupFiles bfile : savesInProgress)
+ {
+ files.add(bfile.getFile());
+ }
+ return files;
+ }
+
public BackupFiles(String filename)
{
this(new File(filename));
{
classInit();
this.file = file;
+
+ // add this file from the save in progress stack
+ addSaveInProgress();
+
BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
.getSavedBackupEntry();
this.suffix = bfpe.suffix;
tidyUpFiles();
}
+ // remove this file from the save in progress stack
+ removeSaveInProgress();
+
return rename;
}
return ret;
}
+ public File getFile()
+ {
+ return file;
+ }
+
public static boolean moveFileToFile(File oldFile, File newFile)
{
Console.initLogger();