+
+ String savedFilename = "";
+ // if extensionOnly is set then reset the filename to the last occurrence of the extension+templateStart and try the match
+ if (extensionMatch)
+ {
+ // only trying to match from extension onwards
+
+ int extensioncharstart = filename
+ .lastIndexOf('.' + base + templateStart);
+ if (extensioncharstart == -1)
+ {
+ return;
+ }
+
+ savedFilename = filename.substring(0, extensioncharstart + 1); // include
+ // the "."
+ filename = filename.substring(extensioncharstart + 1);
+ }
+
+ // full filename match
+
+ // calculate minimum length of a backup filename
+ int minlength = base.length() + template.length()
+ - BackupFiles.NUM_PLACEHOLDER.length() + digits;
+
+ if (!(filename.startsWith(base + templateStart)
+ && filename.endsWith(templateEnd)
+ && filename.length() >= minlength))
+ {
+ // non-starter
+ return;
+ }
+