Merge branch 'documentation/JAL-3407_2.11.1_release' into releases/Release_2_11_1_Branch
[jalview.git] / src / jalview / io / BackupFilenameFilter.java
1 package jalview.io;
2
3 import java.io.File;
4 import java.io.FilenameFilter;
5 import java.io.IOException;
6
7 public class BackupFilenameFilter implements FilenameFilter
8 {
9
10   public String base;
11
12   public String template;
13
14   public int digits;
15
16   public BackupFilenameFilter(String base, String template, int digits)
17   {
18     this.base = base;
19     this.template = template;
20     this.digits = digits;
21   }
22
23   @Override
24   public boolean accept(File dir, String filename)
25   {
26     try
27     {
28       File file = new File(
29               dir.getCanonicalPath() + File.separatorChar + filename);
30       if (file.isDirectory())
31       {
32         // backup files aren't dirs!
33         return false;
34       }
35     } catch (IOException e)
36     {
37       System.out.println("IOException when checking file '" + filename
38               + "' is a backupfile");
39     }
40
41     BackupFilenameParts bffp = new BackupFilenameParts(filename, base,
42             template, digits);
43     return bffp.isBackupFile();
44   }
45
46 }