source: java/installer2/src/net/oni2/aeinstaller/backend/CaseInsensitiveFile.java@ 845

Last change on this file since 845 was 699, checked in by alloc, 12 years ago

AEI2 0.99t:

  • Access to files/folders which can be different in case because of user interaction are now case insensitive
  • Few cleanups
File size: 792 bytes
Line 
1package net.oni2.aeinstaller.backend;
2
3import java.io.File;
4import java.io.FilenameFilter;
5
6/**
7 * @author Christian Illy
8 */
9public 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}
Note: See TracBrowser for help on using the repository browser.