~ubuntu-branches/ubuntu/precise/cmake/precise-updates

« back to all changes in this revision

Viewing changes to Source/kwsys/Glob.cxx

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-11-21 23:30:34 UTC
  • mfrom: (1.13.5)
  • Revision ID: package-import@ubuntu.com-20111121233034-r7r79fmmttg5sn7t
Tags: 2.8.6-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
 
216
216
//----------------------------------------------------------------------------
217
217
void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
218
 
  const kwsys_stl::string& dir, bool dir_only)
 
218
  const kwsys_stl::string& dir)
219
219
{
220
220
  kwsys::Directory d;
221
221
  if ( !d.Load(dir.c_str()) )
258
258
      fullname = dir + "/" + fname;
259
259
      }
260
260
 
261
 
    if ( !dir_only || !kwsys::SystemTools::FileIsDirectory(realname.c_str()) )
262
 
      {
263
 
      if ( (this->Internals->Expressions.size() > 0) && 
 
261
    bool isDir = kwsys::SystemTools::FileIsDirectory(realname.c_str());
 
262
    bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str());
 
263
 
 
264
    if ( isDir && (!isSymLink || this->RecurseThroughSymlinks) )
 
265
      {
 
266
      if (isSymLink)
 
267
        {
 
268
        ++this->FollowedSymlinkCount;
 
269
        }
 
270
      this->RecurseDirectory(start+1, realname);
 
271
      }
 
272
    else
 
273
      {
 
274
      if ( (this->Internals->Expressions.size() > 0) &&
264
275
           this->Internals->Expressions[
265
276
             this->Internals->Expressions.size()-1].find(fname.c_str()) )
266
277
        {
267
278
        this->AddFile(this->Internals->Files, realname.c_str());
268
279
        }
269
280
      }
270
 
    if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) )
271
 
      {
272
 
      bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str());
273
 
      if (!isSymLink || this->RecurseThroughSymlinks)
274
 
        {
275
 
        if (isSymLink)
276
 
          {
277
 
          ++this->FollowedSymlinkCount;
278
 
          }
279
 
        this->RecurseDirectory(start+1, realname, dir_only);
280
 
        }
281
 
      }
282
281
    }
283
282
}
284
283
 
285
284
//----------------------------------------------------------------------------
286
285
void Glob::ProcessDirectory(kwsys_stl::string::size_type start,
287
 
  const kwsys_stl::string& dir, bool dir_only)
 
286
  const kwsys_stl::string& dir)
288
287
{
289
288
  //kwsys_ios::cout << "ProcessDirectory: " << dir << kwsys_ios::endl;
290
289
  bool last = ( start == this->Internals->Expressions.size()-1 );
291
290
  if ( last && this->Recurse )
292
291
    {
293
 
    this->RecurseDirectory(start, dir, dir_only);
 
292
    this->RecurseDirectory(start, dir);
294
293
    return;
295
294
    }
296
295
 
345
344
    // << this->Internals->TextExpressions[start].c_str() << kwsys_ios::endl;
346
345
    //kwsys_ios::cout << "Full name: " << fullname << kwsys_ios::endl;
347
346
 
348
 
    if ( (!dir_only || !last) &&
 
347
    if ( !last &&
349
348
      !kwsys::SystemTools::FileIsDirectory(realname.c_str()) )
350
349
      {
351
350
      continue;
359
358
        }
360
359
      else
361
360
        {
362
 
        this->ProcessDirectory(start+1, realname + "/", dir_only);
 
361
        this->ProcessDirectory(start+1, realname + "/");
363
362
        }
364
363
      }
365
364
    }
462
461
  // Handle network paths
463
462
  if ( skip > 0 )
464
463
    {
465
 
    this->ProcessDirectory(0, fexpr.substr(0, skip) + "/",
466
 
      true);
 
464
    this->ProcessDirectory(0, fexpr.substr(0, skip) + "/");
467
465
    }
468
466
  else
469
467
    {
470
 
    this->ProcessDirectory(0, "/", true);
 
468
    this->ProcessDirectory(0, "/");
471
469
    }
472
470
  return true;
473
471
}