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:
parent
6a9b0b5589
commit
277f1959ad
1 changed files with 18 additions and 16 deletions
|
@ -4,14 +4,14 @@
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
// modification, are permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
// * Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
// this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
// and/or other materials provided with the distribution.
|
||||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
||||||
// may be used to endorse or promote products derived from this software
|
// may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
// without specific prior written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
@ -78,12 +78,15 @@ bool FileIterator::Next(wxString *filename) {
|
||||||
|
|
||||||
// No more items
|
// No more items
|
||||||
if (currentItem >= items.GetCount()) return false;
|
if (currentItem >= items.GetCount()) return false;
|
||||||
|
|
||||||
wxFileName next;
|
wxFileName next;
|
||||||
|
wxString current = items[currentItem];
|
||||||
|
|
||||||
|
currentItem++;
|
||||||
|
|
||||||
// Test if it's a directory
|
// Test if it's a directory
|
||||||
if (wxFileName::DirExists(items[currentItem])) {
|
if (wxFileName::DirExists(current)) {
|
||||||
currentDir.Open(items[currentItem]);
|
currentDir.Open(current);
|
||||||
currentItem++;
|
|
||||||
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,12 +97,11 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entry is neither a file nor a directory, just skip it
|
// Entry is neither a file nor a directory, just skip it
|
||||||
return Next(filename);
|
return Next(filename);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue