Changeset 14993 for trunk/Mars


Ignore:
Timestamp:
03/08/13 15:59:39 (12 years ago)
Author:
tbretz
Message:
Changed Next() in a way that it is not self-referencing anymore.... caused stack overflows with long lists.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mbase/MDirIter.cc

    r14853 r14993  
    348348    // Check for rread perissions
    349349    return !gSystem->AccessPathName(fqp, kReadPermission);
    350 
    351350}
    352351
     
    374373TString MDirIter::Next(Bool_t nocheck)
    375374{
    376     fDirPtr = Open();
    377     if (!fDirPtr)
    378         return "";
    379 
    380     // Get next entry in dir, if existing check validity
    381     const char *n = gSystem->GetDirEntry(fDirPtr);
    382     if (n)
    383         return nocheck || CheckEntry(n) ? ConcatFileName(fCurrentPath->GetName(), n) : Next();
    384 
    385     // Otherwise close directory and try to get next entry
    386     Close();
    387     return Next();
     375    while (1)
     376    {
     377        fDirPtr = Open();
     378        if (!fDirPtr)
     379            break;
     380
     381        // Get next entry in dir, if existing check validity
     382        const char *n = gSystem->GetDirEntry(fDirPtr);
     383        if (!n)
     384        {
     385            // Otherwise close directory and try to get next entry
     386            Close();
     387            continue;
     388        }
     389
     390        if (nocheck || CheckEntry(n))
     391            return ConcatFileName(fCurrentPath->GetName(), n);
     392    }
     393
     394    return "";
    388395}
    389396
Note: See TracChangeset for help on using the changeset viewer.