1 |
package net.oni2.aeinstaller.backend; |
2 |
|
3 |
import java.io.File; |
4 |
import java.io.FilenameFilter; |
5 |
|
6 |
/** |
7 |
* @author Christian Illy |
8 |
*/ |
9 |
public class CaseInsensitiveFile { |
10 |
/** |
11 |
* Get a File for the given parent path and a child name. Return the name as |
12 |
* passed to the function if either parent or a file named that way does not |
13 |
* exist. |
14 |
* |
15 |
* @param parent |
16 |
* Parent path |
17 |
* @param name |
18 |
* Name of file |
19 |
* @return File |
20 |
*/ |
21 |
public static File getCaseInsensitiveFile(File parent, final String name) { |
22 |
if (parent.exists()) { |
23 |
for (File f : parent.listFiles(new FilenameFilter() { |
24 |
@Override |
25 |
public boolean accept(File dir, String fname) { |
26 |
return fname.equalsIgnoreCase(name); |
27 |
} |
28 |
})) { |
29 |
return f; |
30 |
} |
31 |
} |
32 |
return new File(parent, name); |
33 |
} |
34 |
} |