ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/AE/installer2/src/net/oni2/aeinstaller/backend/CaseInsensitiveFile.java
Revision: 699
Committed: Sun Mar 17 17:52:08 2013 UTC (12 years, 6 months ago) by alloc
Content type: text/x-java
File size: 792 byte(s)
Log Message:
AEI2 0.99t:
- Access to files/folders which can be different in case because of user interaction are now case insensitive
- Few cleanups

File Contents

# Content
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 }