under Windows, the case of the includedFiles and of the includedDirectories was influenced by the case used in the include patterns of the fileset. This change fixes it. I am using File.getCanonicalFile() because it is the only way I know to get the real case of a file under Windows. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274865 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -66,6 +66,7 @@ import org.apache.tools.ant.types.selectors.FileSelector; | |||||
| import org.apache.tools.ant.types.selectors.SelectorScanner; | import org.apache.tools.ant.types.selectors.SelectorScanner; | ||||
| import org.apache.tools.ant.types.selectors.SelectorUtils; | import org.apache.tools.ant.types.selectors.SelectorUtils; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| import org.apache.tools.ant.taskdefs.condition.Os; | |||||
| /** | /** | ||||
| * Class for scanning a directory for files/directories which match certain | * Class for scanning a directory for files/directories which match certain | ||||
| @@ -694,6 +695,22 @@ public class DirectoryScanner | |||||
| String currentelement = (String) enum2.nextElement(); | String currentelement = (String) enum2.nextElement(); | ||||
| String originalpattern = (String) newroots.get(currentelement); | String originalpattern = (String) newroots.get(currentelement); | ||||
| File myfile = new File(basedir, currentelement); | File myfile = new File(basedir, currentelement); | ||||
| // we need to call getCanonicalFile here for DOS systems | |||||
| // the reason being that otherwise File will be influenced | |||||
| // by the case of currentelement, which we want to avoid | |||||
| if (Os.isFamily("dos") && myfile.exists()) { | |||||
| try { | |||||
| // getAbsoluteFile() is not enough here unfortunately | |||||
| myfile = myfile.getCanonicalFile(); | |||||
| } | |||||
| catch (Exception ex) { | |||||
| throw new BuildException(ex); | |||||
| } | |||||
| // the variable currentelement is actually telling what | |||||
| // the scan results will contain | |||||
| currentelement = fileUtils.removeLeadingPath(basedir, | |||||
| myfile); | |||||
| } | |||||
| if (!myfile.exists() && !isCaseSensitive) { | if (!myfile.exists() && !isCaseSensitive) { | ||||
| File f = findFileCaseInsensitive(basedir, currentelement); | File f = findFileCaseInsensitive(basedir, currentelement); | ||||
| if (f.exists()) { | if (f.exists()) { | ||||
| @@ -120,11 +120,7 @@ public class DirectoryScannerTest extends BuildFileTest { | |||||
| ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); | ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); | ||||
| ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); | ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); | ||||
| ds.scan(); | ds.scan(); | ||||
| if (Os.isFamily("dos")) { | |||||
| compareFiles(ds, new String[] {"alpha/beta/gamma/GAMMA.XML"}, new String[] {}); | |||||
| } else { | |||||
| compareFiles(ds, new String[] {}, new String[] {}); | |||||
| } | |||||
| compareFiles(ds, new String[] {}, new String[] {}); | |||||
| } | } | ||||
| public void testFullPathMatchesCaseInsensitive() { | public void testFullPathMatchesCaseInsensitive() { | ||||
| @@ -133,13 +129,8 @@ public class DirectoryScannerTest extends BuildFileTest { | |||||
| ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); | ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); | ||||
| ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); | ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); | ||||
| ds.scan(); | ds.scan(); | ||||
| if (Os.isFamily("dos")) { | |||||
| compareFiles(ds, new String[] {"alpha/beta/gamma/GAMMA.XML"}, | |||||
| new String[] {}); | |||||
| } else { | |||||
| compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, | |||||
| new String[] {}); | |||||
| } | |||||
| compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, | |||||
| new String[] {}); | |||||
| } | } | ||||
| public void test2ButCaseInsesitive() { | public void test2ButCaseInsesitive() { | ||||
| @@ -148,15 +139,9 @@ public class DirectoryScannerTest extends BuildFileTest { | |||||
| ds.setIncludes(new String[] {"ALPHA/"}); | ds.setIncludes(new String[] {"ALPHA/"}); | ||||
| ds.setCaseSensitive(false); | ds.setCaseSensitive(false); | ||||
| ds.scan(); | ds.scan(); | ||||
| if (Os.isFamily("dos")) { | |||||
| compareFiles(ds, new String[] {"ALPHA/beta/beta.xml", | |||||
| "ALPHA/beta/gamma/gamma.xml"}, | |||||
| new String[] {"ALPHA", "ALPHA/beta", "ALPHA/beta/gamma"}); | |||||
| } else { | |||||
| compareFiles(ds, new String[] {"alpha/beta/beta.xml", | compareFiles(ds, new String[] {"alpha/beta/beta.xml", | ||||
| "alpha/beta/gamma/gamma.xml"}, | "alpha/beta/gamma/gamma.xml"}, | ||||
| new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); | new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); | ||||
| } | |||||
| } | } | ||||
| public void testAllowSymlinks() { | public void testAllowSymlinks() { | ||||