From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: __file_tree_walk vs. files created by callback Date: 25 Mar 2001 15:43:11 GMT Organization: Aachen University of Technology (RWTH) Lines: 36 Message-ID: <99l3mf$ek6$1@nets3.rz.RWTH-Aachen.DE> References: <200103180634 DOT f2I6Ywq14286 AT unagi DOT cis DOT upenn DOT edu> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 985534991 14982 137.226.32.75 (25 Mar 2001 15:43:11 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 25 Mar 2001 15:43:11 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com David Graff wrote: [...] > __file_tree_walk( base_path, filter_func ); > ... > int filter_func( const char *fspec, const struct ffblk *ff ) > { > /* if fspec refers to a data file, and the contents of this file meet > * certain conditions, come up with a modified copy of fspec, and use this > * new name to create a new output file in the same directory as fspec; > * pass the contents of fspec to the new file (with some modifications), > * then close both files > */ > } For this type of usage, __file_tree_walk() may not be the correct concept. At least not in the way you use it. You could return it to 'expected' behaviour by having the filter function store the set of files that do have to be modified, by full pathname, and operate on the stored list only after the file tree walking has finished. The difference is the same that exists between the 'find' idioms: find . -type f -name 'foo*.dat' -exec operation {} \; and find . -type f -name 'foo*.dat' | xargs operation Whenever 'operation' causes modifications to the files and directories visited by the 'find', strange error messages will often stream out of 'find', despite some valiant efforts by the GNU find authors to detect such modifications happening under its very feet. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.