Fixed reset FileIterator.

This commit is contained in:
Christian P. MOMON 2010-06-21 04:29:09 +02:00
parent 4e522c4576
commit 6e72560ba7
2 changed files with 17 additions and 5 deletions

View file

@ -127,6 +127,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
this.removeAllElements(); this.removeAllElements();
this.add(firstState); this.add(firstState);
} }
shift();
} }
@ -198,7 +200,7 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
/** /**
* *
*/ */
protected File currentFile() public File currentFile()
{ {
File result; File result;
@ -270,6 +272,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
{ {
result = false; result = false;
} }
//System.out.println("FOLLOWWWWW=[" + file.getPath() + "][" + this.followLinks + "][" + isLink(file) + "][" + result + "]");
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -277,6 +281,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
result = false; result = false;
} }
// //
return(result); return(result);
} }
@ -384,7 +390,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
int result; int result;
result = 0; result = 0;
while (this.next() != null) File f;
while ((f = this.next()) != null)
{ {
result += 1; result += 1;
} }

View file

@ -43,7 +43,9 @@ public class FileIteratorTester
try try
{ {
File f = new File("TestTree/DirectoryOne/titi2"); //File f = new File("TestTree/DirectoryOne/titi2");
//File f = new File("/home/cpm/.kde//cache-cpmstar");
File f = new File("tests/TestTree/xine.jpg");
System.out.println("exists=" + f.exists()); System.out.println("exists=" + f.exists());
System.out.println("canonical path = " + f.getCanonicalPath()); System.out.println("canonical path = " + f.getCanonicalPath());
System.out.println("absolute path = " + f.getAbsolutePath()); System.out.println("absolute path = " + f.getAbsolutePath());
@ -58,10 +60,13 @@ public class FileIteratorTester
System.out.println("----"); System.out.println("----");
//FileIterator i = new FileIterator(new File("tests/TestTree")); //FileIterator i = new FileIterator(new File("tests/TestTree"));
FileIterator i = new FileIterator(new File("tests/TestTree/xine.jpg"), null, true);
//FileIterator i = new FileIterator(new File("/home/cpm/.kde/cache-cpmstar"), ".*cache.*", false);
//FileIterator i = new FileIterator(new File("tests/TestTree"), ".*dsc.*", false); //FileIterator i = new FileIterator(new File("tests/TestTree"), ".*dsc.*", false);
//FileIterator i = new FileIterator(new File("/home/cpm/Images/Photos/")); //FileIterator i = new FileIterator(new File("/home/cpm/Images/Photos/"));
//FileIterator i = new FileIterator(new File("/home/cpm/Images/Photos/"), ".*\\.(JPG|jpg)", false); //FileIterator i = new FileIterator(new File("/home/cpm/Images/Photos/"), ".*\\.(JPG|jpg)", false);
FileIterator i = new FileIterator(new File("/home/cpm/Images/Photos/"), ".*anni_moi.*", false); //FileIterator i = new FileIterator(new File("/home/cpm/Images/Photos/"), ".*anni_moi.*", false);
while (i.hasNext()) while (i.hasNext())
{ {
//System.out.println(i.toString()); //System.out.println(i.toString());