Iterate over wxTextFile without using indices
Using iterator methods is less error-prone (there is no danger of using an invalid index) and slightly shorter and more clear too.
This commit is contained in:
@@ -307,10 +307,10 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
|
|||||||
wxTextFile textFile;
|
wxTextFile textFile;
|
||||||
if ( textFile.Open(dirsFile.GetFullPath()) )
|
if ( textFile.Open(dirsFile.GetFullPath()) )
|
||||||
{
|
{
|
||||||
size_t i;
|
for ( wxString line = textFile.GetFirstLine();
|
||||||
for (i = 0; i < textFile.GetLineCount(); i++)
|
!textFile.Eof();
|
||||||
|
line = textFile.GetNextLine() )
|
||||||
{
|
{
|
||||||
wxString line(textFile[i]);
|
|
||||||
int pos = line.Find(userDirId);
|
int pos = line.Find(userDirId);
|
||||||
if (pos != wxNOT_FOUND)
|
if (pos != wxNOT_FOUND)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user