| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.util; |
| 22 |
|
|
| 23 |
|
import java.io.File; |
| 24 |
|
import java.io.IOException; |
| 25 |
|
import java.net.MalformedURLException; |
| 26 |
|
import java.net.URL; |
| 27 |
|
import java.nio.file.FileSystems; |
| 28 |
|
import java.nio.file.FileVisitOption; |
| 29 |
|
import java.nio.file.FileVisitResult; |
| 30 |
|
import java.nio.file.Files; |
| 31 |
|
import java.nio.file.Path; |
| 32 |
|
import java.nio.file.PathMatcher; |
| 33 |
|
import java.nio.file.Paths; |
| 34 |
|
import java.nio.file.SimpleFileVisitor; |
| 35 |
|
import java.nio.file.attribute.BasicFileAttributes; |
| 36 |
|
import java.util.ArrayList; |
| 37 |
|
import java.util.Collections; |
| 38 |
|
import java.util.EnumSet; |
| 39 |
|
import java.util.HashSet; |
| 40 |
|
import java.util.List; |
| 41 |
|
import java.util.Set; |
| 42 |
|
import java.util.stream.Collectors; |
| 43 |
|
|
| |
|
| 84.8% |
Uncovered Elements: 43 (283) |
Complexity: 75 |
Complexity Density: 0.43 |
|
| 44 |
|
public class FileUtils |
| 45 |
|
{ |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
175 |
public static List<File> getFilesFromGlob(String pattern)... |
| 53 |
|
{ |
| 54 |
175 |
return getFilesFromGlob(pattern, true); |
| 55 |
|
} |
| 56 |
|
|
| |
|
| 87% |
Uncovered Elements: 6 (46) |
Complexity: 13 |
Complexity Density: 0.43 |
|
| 57 |
193 |
public static List<File> getFilesFromGlob(String pattern,... |
| 58 |
|
boolean allowSingleFilenameThatDoesNotExist) |
| 59 |
|
{ |
| 60 |
193 |
pattern = substituteHomeDir(pattern); |
| 61 |
193 |
String relativePattern = pattern.startsWith(File.separator) ? null |
| 62 |
|
: pattern; |
| 63 |
193 |
List<File> files = new ArrayList<>(); |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
193 |
int firstGlobChar = -1; |
| 72 |
193 |
boolean foundGlobChar = false; |
| 73 |
193 |
for (char c : new char[] { '*', '{', '?' }) |
| 74 |
|
{ |
| 75 |
579 |
if (pattern.indexOf(c) > -1 |
| 76 |
|
&& (pattern.indexOf(c) < firstGlobChar || !foundGlobChar)) |
| 77 |
|
{ |
| 78 |
65 |
firstGlobChar = pattern.indexOf(c); |
| 79 |
65 |
foundGlobChar = true; |
| 80 |
|
} |
| 81 |
|
} |
| 82 |
193 |
int lastFS = pattern.lastIndexOf(File.separatorChar, firstGlobChar); |
| 83 |
193 |
if (foundGlobChar) |
| 84 |
|
{ |
| 85 |
65 |
String pS = pattern.substring(0, lastFS + 1); |
| 86 |
65 |
String rest = pattern.substring(lastFS + 1); |
| 87 |
65 |
if ("".equals(pS)) |
| 88 |
|
{ |
| 89 |
0 |
pS = "."; |
| 90 |
|
} |
| 91 |
65 |
Path parentDir = Paths.get(pS); |
| 92 |
65 |
if (parentDir.toFile().exists()) |
| 93 |
|
{ |
| 94 |
65 |
try |
| 95 |
|
{ |
| 96 |
65 |
String glob = "glob:" + parentDir.toString() + File.separator |
| 97 |
|
+ rest; |
| 98 |
|
|
| 99 |
65 |
if (System.getProperty("os.name").indexOf("Win") >= 0) |
| 100 |
|
{ |
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
0 |
glob = glob.replaceAll("\\\\", "\\\\\\\\"); |
| 105 |
|
} |
| 106 |
65 |
PathMatcher pm = FileSystems.getDefault().getPathMatcher(glob); |
| 107 |
65 |
int maxDepth = rest.contains("**") ? 1028 |
| 108 |
|
: (int) (rest.chars() |
| 109 |
|
.filter(ch -> ch == File.separatorChar).count()) |
| 110 |
|
+ 1; |
| 111 |
|
|
| 112 |
65 |
Files.walkFileTree(parentDir, |
| 113 |
|
EnumSet.of(FileVisitOption.FOLLOW_LINKS), maxDepth, |
| 114 |
|
new SimpleFileVisitor<Path>() |
| 115 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 116 |
6475 |
@Override... |
| 117 |
|
public FileVisitResult visitFile(Path path, |
| 118 |
|
BasicFileAttributes attrs) throws IOException |
| 119 |
|
{ |
| 120 |
6475 |
if (pm.matches(path)) |
| 121 |
|
{ |
| 122 |
3185 |
files.add(path.toFile()); |
| 123 |
|
} |
| 124 |
6475 |
return FileVisitResult.CONTINUE; |
| 125 |
|
} |
| 126 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 127 |
0 |
@Override... |
| 128 |
|
public FileVisitResult visitFileFailed(Path file, |
| 129 |
|
IOException exc) throws IOException |
| 130 |
|
{ |
| 131 |
0 |
return FileVisitResult.CONTINUE; |
| 132 |
|
} |
| 133 |
|
}); |
| 134 |
|
} catch (IOException e) |
| 135 |
|
{ |
| 136 |
0 |
e.printStackTrace(); |
| 137 |
|
} |
| 138 |
|
} |
| 139 |
|
} |
| 140 |
|
else |
| 141 |
|
{ |
| 142 |
|
|
| 143 |
128 |
File f = new File(pattern); |
| 144 |
128 |
if (allowSingleFilenameThatDoesNotExist || f.exists()) |
| 145 |
|
{ |
| 146 |
120 |
files.add(f); |
| 147 |
|
} |
| 148 |
|
} |
| 149 |
193 |
Collections.sort(files); |
| 150 |
|
|
| 151 |
193 |
return files; |
| 152 |
|
} |
| 153 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 154 |
150 |
public static List<String> getFilenamesFromGlob(String pattern)... |
| 155 |
|
{ |
| 156 |
|
|
| 157 |
150 |
return getFilesFromGlob(pattern).stream().map(f -> f.getPath()) |
| 158 |
|
.collect(Collectors.toList()); |
| 159 |
|
} |
| 160 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 161 |
386 |
public static String substituteHomeDir(String path)... |
| 162 |
|
{ |
| 163 |
386 |
return path.startsWith("~" + File.separator) |
| 164 |
|
? System.getProperty("user.home") + path.substring(1) |
| 165 |
|
: path; |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 171 |
78 |
public static String getBasename(File file)... |
| 172 |
|
{ |
| 173 |
78 |
return getBasenameOrExtension(file, false); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 179 |
10 |
public static String getExtension(File file)... |
| 180 |
|
{ |
| 181 |
10 |
return getBasenameOrExtension(file, true); |
| 182 |
|
} |
| 183 |
|
|
| |
|
| 82.4% |
Uncovered Elements: 3 (17) |
Complexity: 5 |
Complexity Density: 0.56 |
|
| 184 |
88 |
public static String getBasenameOrExtension(File file, boolean extension)... |
| 185 |
|
{ |
| 186 |
88 |
if (file == null) |
| 187 |
0 |
return null; |
| 188 |
|
|
| 189 |
88 |
String value = null; |
| 190 |
88 |
String filename = file.getName(); |
| 191 |
88 |
int lastDot = filename.lastIndexOf('.'); |
| 192 |
88 |
if (lastDot > 0) |
| 193 |
|
{ |
| 194 |
87 |
value = extension ? filename.substring(lastDot + 1) |
| 195 |
|
: filename.substring(0, lastDot); |
| 196 |
|
} |
| 197 |
|
else |
| 198 |
|
{ |
| 199 |
1 |
value = extension ? "" : filename; |
| 200 |
|
} |
| 201 |
88 |
return value; |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| |
|
| 69.2% |
Uncovered Elements: 4 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 208 |
104 |
public static String getDirname(File file)... |
| 209 |
|
{ |
| 210 |
104 |
if (file == null) |
| 211 |
0 |
return null; |
| 212 |
|
|
| 213 |
104 |
String dirname = null; |
| 214 |
104 |
File p = file.getParentFile(); |
| 215 |
104 |
if (p == null) |
| 216 |
|
{ |
| 217 |
0 |
p = new File("."); |
| 218 |
|
} |
| 219 |
104 |
File d = new File(substituteHomeDir(p.getPath())); |
| 220 |
104 |
dirname = d.getPath(); |
| 221 |
104 |
return dirname; |
| 222 |
|
} |
| 223 |
|
|
| |
|
| 91.3% |
Uncovered Elements: 2 (23) |
Complexity: 5 |
Complexity Density: 0.29 |
|
| 224 |
19 |
public static String convertWildcardsToPath(String value, String wildcard,... |
| 225 |
|
String dirname, String basename) |
| 226 |
|
{ |
| 227 |
19 |
if (value == null) |
| 228 |
|
{ |
| 229 |
0 |
return null; |
| 230 |
|
} |
| 231 |
19 |
StringBuilder path = new StringBuilder(); |
| 232 |
19 |
int lastFileSeparatorIndex = value.lastIndexOf(File.separatorChar); |
| 233 |
19 |
int wildcardBeforeIndex = value.indexOf(wildcard); |
| 234 |
19 |
if (lastFileSeparatorIndex > wildcard.length() - 1 |
| 235 |
|
&& wildcardBeforeIndex < lastFileSeparatorIndex) |
| 236 |
|
{ |
| 237 |
12 |
path.append(value.substring(0, wildcardBeforeIndex)); |
| 238 |
12 |
path.append(dirname); |
| 239 |
12 |
path.append(value.substring(wildcardBeforeIndex + wildcard.length(), |
| 240 |
|
lastFileSeparatorIndex + 1)); |
| 241 |
|
} |
| 242 |
|
else |
| 243 |
|
{ |
| 244 |
7 |
path.append(value.substring(0, lastFileSeparatorIndex + 1)); |
| 245 |
|
} |
| 246 |
19 |
int wildcardAfterIndex = value.indexOf(wildcard, |
| 247 |
|
lastFileSeparatorIndex); |
| 248 |
19 |
if (wildcardAfterIndex > lastFileSeparatorIndex) |
| 249 |
|
{ |
| 250 |
14 |
path.append(value.substring(lastFileSeparatorIndex + 1, |
| 251 |
|
wildcardAfterIndex)); |
| 252 |
14 |
path.append(basename); |
| 253 |
14 |
path.append(value.substring(wildcardAfterIndex + wildcard.length())); |
| 254 |
|
} |
| 255 |
|
else |
| 256 |
|
{ |
| 257 |
5 |
path.append(value.substring(lastFileSeparatorIndex + 1)); |
| 258 |
|
} |
| 259 |
19 |
return path.toString(); |
| 260 |
|
} |
| 261 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 262 |
114 |
public static File getParentDir(File file)... |
| 263 |
|
{ |
| 264 |
114 |
if (file == null) |
| 265 |
|
{ |
| 266 |
0 |
return null; |
| 267 |
|
} |
| 268 |
114 |
File parentDir = file.getAbsoluteFile().getParentFile(); |
| 269 |
114 |
return parentDir; |
| 270 |
|
} |
| 271 |
|
|
| |
|
| 70.8% |
Uncovered Elements: 7 (24) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 272 |
114 |
public static boolean checkParentDir(File file, boolean mkdirs)... |
| 273 |
|
{ |
| 274 |
114 |
if (file == null) |
| 275 |
|
{ |
| 276 |
0 |
return false; |
| 277 |
|
} |
| 278 |
114 |
File parentDir = getParentDir(file); |
| 279 |
114 |
if (parentDir.exists()) |
| 280 |
|
{ |
| 281 |
|
|
| 282 |
112 |
return true; |
| 283 |
|
} |
| 284 |
|
|
| 285 |
2 |
if (!mkdirs) |
| 286 |
|
{ |
| 287 |
0 |
return false; |
| 288 |
|
} |
| 289 |
|
|
| 290 |
2 |
Path path = file.toPath(); |
| 291 |
20 |
for (int i = 0; i < path.getNameCount(); i++) |
| 292 |
|
{ |
| 293 |
18 |
Path p = path.getName(i); |
| 294 |
18 |
if ("..".equals(p.toString())) |
| 295 |
|
{ |
| 296 |
0 |
LaunchUtils.syserr(true, false, |
| 297 |
|
"Cautiously not running mkdirs on " + file.toString() |
| 298 |
|
+ " because the path to be made contains '..'"); |
| 299 |
0 |
return false; |
| 300 |
|
} |
| 301 |
|
} |
| 302 |
|
|
| 303 |
2 |
return mkdirs(parentDir); |
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
@param |
| 310 |
|
|
| 311 |
|
@return |
| 312 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 313 |
15 |
public static String getExtension(String filename)... |
| 314 |
|
{ |
| 315 |
15 |
return getBaseOrExtension(filename, true); |
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
@param |
| 326 |
|
@return |
| 327 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 328 |
15 |
public static String getBase(String filename)... |
| 329 |
|
{ |
| 330 |
15 |
return getBaseOrExtension(filename, false); |
| 331 |
|
} |
| 332 |
|
|
| |
|
| 86.7% |
Uncovered Elements: 4 (30) |
Complexity: 9 |
Complexity Density: 0.5 |
|
| 333 |
30 |
public static String getBaseOrExtension(String filename0,... |
| 334 |
|
boolean extension) |
| 335 |
|
{ |
| 336 |
30 |
if (filename0 == null) |
| 337 |
|
{ |
| 338 |
0 |
return null; |
| 339 |
|
} |
| 340 |
30 |
String filename = filename0; |
| 341 |
30 |
boolean isUrl = false; |
| 342 |
30 |
if (HttpUtils.startsWithHttpOrHttps(filename)) |
| 343 |
|
{ |
| 344 |
10 |
try |
| 345 |
|
{ |
| 346 |
10 |
URL url = new URL(filename); |
| 347 |
10 |
filename = url.getPath(); |
| 348 |
10 |
isUrl = true; |
| 349 |
|
} catch (MalformedURLException e) |
| 350 |
|
{ |
| 351 |
|
|
| 352 |
|
} |
| 353 |
|
} |
| 354 |
30 |
int dot = filename.lastIndexOf('.'); |
| 355 |
30 |
int slash = filename.lastIndexOf('/'); |
| 356 |
30 |
if (!File.separator.equals("/") && !isUrl) |
| 357 |
|
{ |
| 358 |
0 |
slash = filename.lastIndexOf(File.separator); |
| 359 |
|
} |
| 360 |
|
|
| 361 |
|
|
| 362 |
30 |
boolean hasExtension = dot > slash + 1; |
| 363 |
30 |
if (extension) |
| 364 |
|
{ |
| 365 |
15 |
return hasExtension ? filename.substring(dot + 1) : null; |
| 366 |
|
} |
| 367 |
|
else |
| 368 |
|
{ |
| 369 |
15 |
dot = filename0.lastIndexOf('.'); |
| 370 |
15 |
return hasExtension ? filename0.substring(0, dot + 1) : filename0; |
| 371 |
|
} |
| 372 |
|
} |
| 373 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 374 |
2 |
public static Path getCanonicalPath(Path path)... |
| 375 |
|
{ |
| 376 |
2 |
return path.normalize(); |
| 377 |
|
} |
| 378 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 379 |
2 |
public static Path getCanonicalPath(File file)... |
| 380 |
|
{ |
| 381 |
2 |
return getCanonicalPath(file.toPath()); |
| 382 |
|
} |
| 383 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 384 |
0 |
public static Path getCanonicalPath(String pathString)... |
| 385 |
|
{ |
| 386 |
0 |
return getCanonicalPath(Paths.get(pathString)); |
| 387 |
|
} |
| 388 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 389 |
0 |
public static File getCanonicalFile(File file)... |
| 390 |
|
{ |
| 391 |
0 |
return getCanonicalPath(file).toFile(); |
| 392 |
|
} |
| 393 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 394 |
0 |
public static File getCanonicalFile(String pathString)... |
| 395 |
|
{ |
| 396 |
0 |
return getCanonicalPath(Paths.get(pathString)).toFile(); |
| 397 |
|
} |
| 398 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 399 |
2 |
public static boolean mkdirs(File file)... |
| 400 |
|
{ |
| 401 |
2 |
try |
| 402 |
|
{ |
| 403 |
2 |
Files.createDirectories(getCanonicalPath(file)); |
| 404 |
2 |
return file.exists(); |
| 405 |
|
} catch (IOException e) |
| 406 |
|
{ |
| 407 |
0 |
LaunchUtils.syserr(true, false, "Failed to make directory " + file |
| 408 |
|
+ "\n" + e.getStackTrace()); |
| 409 |
|
} |
| 410 |
0 |
return false; |
| 411 |
|
} |
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
| 416 |
|
|
| 417 |
|
|
| 418 |
|
|
| 419 |
|
|
| 420 |
|
|
| 421 |
|
|
| 422 |
|
|
| 423 |
|
@param |
| 424 |
|
@param |
| 425 |
|
@param |
| 426 |
|
@param |
| 427 |
|
@param |
| 428 |
|
@return |
| 429 |
|
|
| |
|
| 93.4% |
Uncovered Elements: 5 (76) |
Complexity: 14 |
Complexity Density: 0.26 |
|
| 430 |
7 |
public static List<File> getMatchingVersionedFiles(String[] templates,... |
| 431 |
|
String[] roots, String[] versionWhitelist, |
| 432 |
|
String[] versionBlacklist, String versionSeparator, |
| 433 |
|
boolean exists) |
| 434 |
|
{ |
| 435 |
7 |
Set<File> matchingFiles = new HashSet<>(); |
| 436 |
7 |
if (templates == null) |
| 437 |
|
{ |
| 438 |
0 |
ErrorLog.errPrintln( |
| 439 |
|
"getMatchingVersionedFiles called with a null template array"); |
| 440 |
0 |
List<File> files = new ArrayList<File>(); |
| 441 |
0 |
files.addAll(matchingFiles); |
| 442 |
0 |
return files; |
| 443 |
|
} |
| 444 |
|
|
| 445 |
7 |
for (String template : templates) |
| 446 |
|
{ |
| 447 |
7 |
ErrorLog.errPrintln("Using template '" + template + "'"); |
| 448 |
7 |
for (String root : roots) |
| 449 |
|
{ |
| 450 |
14 |
ErrorLog.errPrintln("Using root '" + root + "'"); |
| 451 |
|
|
| 452 |
|
|
| 453 |
14 |
if (versionBlacklist != null) |
| 454 |
|
{ |
| 455 |
10 |
String globMatch = String.format(template, root, "*"); |
| 456 |
10 |
ErrorLog.errPrintln("Using glob '" + globMatch + "'"); |
| 457 |
10 |
List<File> foundFiles = FileUtils.getFilesFromGlob(globMatch, |
| 458 |
|
false); |
| 459 |
10 |
for (File found : foundFiles) |
| 460 |
|
{ |
| 461 |
15 |
ErrorLog.errPrintln("Checking " + found.getPath() + " is okay"); |
| 462 |
15 |
boolean add = true; |
| 463 |
15 |
for (String notVersion : versionBlacklist) |
| 464 |
|
{ |
| 465 |
20 |
StringBuilder vSB = new StringBuilder(); |
| 466 |
20 |
if (versionSeparator != null) |
| 467 |
|
{ |
| 468 |
15 |
vSB.append(versionSeparator); |
| 469 |
|
} |
| 470 |
20 |
vSB.append(notVersion); |
| 471 |
20 |
String versionString = vSB.toString(); |
| 472 |
20 |
if (String.format(template, root, versionString) |
| 473 |
|
.equals(found.getPath())) |
| 474 |
|
{ |
| 475 |
8 |
add = false; |
| 476 |
8 |
ErrorLog.errPrintln( |
| 477 |
|
"Not adding " + found.getPath() + ": version '" |
| 478 |
|
+ notVersion + "' is in the blacklist"); |
| 479 |
8 |
break; |
| 480 |
|
} |
| 481 |
|
} |
| 482 |
15 |
if (add) |
| 483 |
|
{ |
| 484 |
7 |
ErrorLog.errPrintln("Adding " + found.getPath() + " to list"); |
| 485 |
7 |
matchingFiles.add(found); |
| 486 |
|
} |
| 487 |
|
} |
| 488 |
|
|
| 489 |
10 |
if (versionSeparator != null) |
| 490 |
|
{ |
| 491 |
|
|
| 492 |
8 |
String nonVersioned = String.format(template, root, ""); |
| 493 |
8 |
matchingFiles.addAll( |
| 494 |
|
FileUtils.getFilesFromGlob(nonVersioned, false)); |
| 495 |
|
} |
| 496 |
|
} |
| 497 |
|
|
| 498 |
|
|
| 499 |
|
|
| 500 |
14 |
if (versionWhitelist != null) |
| 501 |
|
{ |
| 502 |
10 |
ErrorLog.errPrintln("Adding " + versionWhitelist.length |
| 503 |
|
+ " whitelist versions"); |
| 504 |
10 |
for (String addVersion : versionWhitelist) |
| 505 |
|
{ |
| 506 |
10 |
StringBuilder vSB = new StringBuilder(); |
| 507 |
10 |
if (versionSeparator != null) |
| 508 |
|
{ |
| 509 |
8 |
vSB.append(versionSeparator); |
| 510 |
|
} |
| 511 |
10 |
vSB.append(addVersion); |
| 512 |
10 |
String versionString = vSB.toString(); |
| 513 |
10 |
String versionPath = String.format(template, root, |
| 514 |
|
versionString); |
| 515 |
10 |
ErrorLog.errPrintln( |
| 516 |
|
"Adding whitelist path '" + versionPath + "'"); |
| 517 |
10 |
File file = new File(versionPath); |
| 518 |
10 |
if (file.exists() || !exists) |
| 519 |
|
{ |
| 520 |
6 |
matchingFiles.add(file); |
| 521 |
|
} |
| 522 |
|
} |
| 523 |
|
|
| 524 |
10 |
if (versionSeparator != null) |
| 525 |
|
{ |
| 526 |
|
|
| 527 |
8 |
String nonVersioned = String.format(template, root, ""); |
| 528 |
8 |
File file = new File(nonVersioned); |
| 529 |
8 |
if (file.exists() || !exists) |
| 530 |
|
{ |
| 531 |
2 |
matchingFiles.add(file); |
| 532 |
|
} |
| 533 |
|
} |
| 534 |
|
} |
| 535 |
|
} |
| 536 |
|
} |
| 537 |
|
|
| 538 |
7 |
List<File> files = new ArrayList<File>(); |
| 539 |
7 |
files.addAll(matchingFiles); |
| 540 |
7 |
return files; |
| 541 |
|
} |
| 542 |
|
} |