Fixed reset FileIterator.
This commit is contained in:
parent
4e522c4576
commit
6e72560ba7
2 changed files with 17 additions and 5 deletions
|
@ -127,6 +127,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
|
|||
this.removeAllElements();
|
||||
this.add(firstState);
|
||||
}
|
||||
|
||||
shift();
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,7 +200,7 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
|
|||
/**
|
||||
*
|
||||
*/
|
||||
protected File currentFile()
|
||||
public File currentFile()
|
||||
{
|
||||
File result;
|
||||
|
||||
|
@ -270,6 +272,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
|
|||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
//System.out.println("FOLLOWWWWW=[" + file.getPath() + "][" + this.followLinks + "][" + isLink(file) + "][" + result + "]");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -277,6 +281,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
|
|||
result = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
return(result);
|
||||
}
|
||||
|
@ -384,7 +390,8 @@ public class FileIterator extends Vector<FileIteratorState> implements Iterator<
|
|||
int result;
|
||||
|
||||
result = 0;
|
||||
while (this.next() != null)
|
||||
File f;
|
||||
while ((f = this.next()) != null)
|
||||
{
|
||||
result += 1;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,9 @@ public class FileIteratorTester
|
|||
|
||||
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("canonical path = " + f.getCanonicalPath());
|
||||
System.out.println("absolute path = " + f.getAbsolutePath());
|
||||
|
@ -58,10 +60,13 @@ public class FileIteratorTester
|
|||
|
||||
System.out.println("----");
|
||||
//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("/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/"), ".*anni_moi.*", false);
|
||||
//FileIterator i = new FileIterator(new File("/home/cpm/Images/Photos/"), ".*anni_moi.*", false);
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
//System.out.println(i.toString());
|
||||
|
|
Loading…
Reference in a new issue