|
From: <cr...@us...> - 2009-04-13 14:01:17
|
Revision: 5262
http://jnode.svn.sourceforge.net/jnode/?rev=5262&view=rev
Author: crawley
Date: 2009-04-13 13:24:06 +0000 (Mon, 13 Apr 2009)
Log Message:
-----------
Fix for bug where expanding the pattern "/tmp/*" gave strings with the
leading "/" missing.
Modified Paths:
--------------
trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java
trunk/shell/src/test/org/jnode/test/shell/PathnamePatternTest.java
Modified: trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java
===================================================================
--- trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-04-13 11:02:36 UTC (rev 5261)
+++ trunk/shell/src/shell/org/jnode/shell/PathnamePattern.java 2009-04-13 13:24:06 UTC (rev 5262)
@@ -252,6 +252,9 @@
for (File match : matches) {
String name = match.getName();
+ if (pos == 0 && isAbsolute) {
+ name = File.separator + name;
+ }
if (pos == pattern.length - 1) {
res.add(name);
} else if (match.isDirectory()) {
Modified: trunk/shell/src/test/org/jnode/test/shell/PathnamePatternTest.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/PathnamePatternTest.java 2009-04-13 11:02:36 UTC (rev 5261)
+++ trunk/shell/src/test/org/jnode/test/shell/PathnamePatternTest.java 2009-04-13 13:24:06 UTC (rev 5262)
@@ -20,6 +20,9 @@
package org.jnode.test.shell;
+import java.io.File;
+import java.util.LinkedList;
+
import junit.framework.TestCase;
import org.jnode.shell.PathnamePattern;
@@ -80,4 +83,17 @@
assertEquals("PathnamePattern{source='*',absolute=false,pattern=['^(|[^\\.].*)$']}",
PathnamePattern.compilePathPattern("*", DF).toRegexString());
}
+
+ public void testExpand() {
+ PathnamePattern pat = PathnamePattern.compilePathPattern("/tmp/*");
+ LinkedList<String> list = pat.expand(new File("."));
+ for (String path : list) {
+ assertTrue(new File(path).exists());
+ }
+ pat = PathnamePattern.compilePathPattern("*");
+ list = pat.expand(new File("."));
+ for (String path : list) {
+ assertTrue(new File(path).exists());
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|