travirse the tree

danny danny@3rdplanetsoftware.com
Sat Jul 27 12:10:00 GMT 2002


Hey Now Gcc People,

I got a new one. This may not be the form for it but here goes...

So maybe u remember I was working w/ recursion. My recursive program
traverses the linux directory. Using g++ the recursive part works fine.

I am using readdir() to read the directory and stat() to let me know if
a file is a sub directory, symbolic link, or a file.

This seems to work until I get here:

/home/danny/.gnome/Desktop/Home Directory.

My program thinks Home Directory is a directory and not a symbolic link.
Thus this recursive program is doomed to infinite loopism!

I here is the code I use to test for symbolic link.

if  ( S_ISLNK(aFileStat.st_mode) || (aFileStat.st_mode & S_IFLNK ) )
  return 0;

As u c I have tried both methods of checking for a symbolic link and
both fail on this directory. Any ideas why?

Thanks
  Danny




More information about the Gcc-help mailing list