Re: ftw and CTree



>> >end use functions such as opendir(), readdir(), ...  These all have
>> >manual pages e.g. man 3 opendir.
>> 
>> see also ftw(3) for an easy way to recursively walk a directory tree.
>
>
>I read about this function in the libc info pages. Wow. It sounds too good
>to be true.
>
>How would I use it to recreate a directory hierarchy in my CTree
>widget? Right now I have a recursive function: 

int somefunc (const char *path, struct stat *statbuf, int flag)
{
	if (flag & FTW_F) {
	    /* add `path' to tree */
        }
        return 0;
}

....  ftw ("/start", somefunc, 60);

Note that the pointers to the GtkCTree or whatever have to be globals
or similar, because the designers of ftw(3) had not heard of the idea
of a passed-in user-pointer :(

The order will match that of scandir - you can't change this other
than by sorting the tree or some intermediate data structure after the
fact. 

--p





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]