[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: (followup) Re: [despammed] Best way to recursive folders?
From: Jonathan Belson <jon () witchspace ! com>
Date: 2003-05-04 17:01:04
[Download RAW message or body]
Hiya
>>>You can combine the above approaches: When scanning the first directory,
>>>push any directories to a stack. When done with this directory, take the
>>>top directory and process that in the same way. As this is tail
>>>recursion, it can be replaced with a simple look. In psedo code, in
>>>pseodu C++:
>>>
>>>stack<Directories> dirs_to_be_processed;
>>>do {
>>> for each file in diretory{
>>> if (file is a directory)
>>> dirs_to_be_processed.push(file);
>>> processFile(file);
>>> }
>>>} while (!.stack.empty())
Isn't this code going to fail if the current directory has a link to
a parent directory? GNU grep with the '-r' option keeps track of
the inode device and number for each file to detect recursive loops.
See grep.c/grepdir() for the code in question.
--Jon
http://www.witchspace.com
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic