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