We should still increment currentItem when the file and dir tests both return false, as otherwise we get into infinite recursion processing the same item.

Originally committed to SVN as r4172.
This commit is contained in:
Kevin Ollivier 2010-03-13 17:43:47 +00:00
parent 6a9b0b5589
commit 277f1959ad

View file

@ -80,10 +80,13 @@ bool FileIterator::Next(wxString *filename) {
if (currentItem >= items.GetCount()) return false;
wxFileName next;
// Test if it's a directory
if (wxFileName::DirExists(items[currentItem])) {
currentDir.Open(items[currentItem]);
wxString current = items[currentItem];
currentItem++;
// Test if it's a directory
if (wxFileName::DirExists(current)) {
currentDir.Open(current);
if (currentDir.GetFirst(filename, "", wxDIR_FILES)) {
wxString path = currentDir.GetName();
*filename = wxFileName(path, *filename).GetFullPath();
@ -94,9 +97,8 @@ bool FileIterator::Next(wxString *filename) {
return Next(filename);
}
// Test if it's a file
if (wxFileName::FileExists(items[currentItem])) {
*filename = items[currentItem];
currentItem++;
if (wxFileName::FileExists(current)) {
*filename = current;
return true;
}