On Wednesday, February 23, 2011 at 3:38 PM, Cameron Cole wrote: Recursion is the trick. Here is a partial function we use to loop through > all the files in our project hunting for DFM files to modify (source is old > from Delphi3 and there are cleaner ways to do some of it): >
Cameron, I hate to throw cold water on an attempt to be helpful, but I see two issues with your solution: First, it is missing the call to SysUtils.FindClose. This leaks resources of some kind, which will eventually cause trouble. (However, it might be a long time, and I heard a rumor somewhere that some versions of Windows will garbage-collect file-find handles, in an attempt to work around this common problem in application code.) Second, for the general case it is usually better to scan each directory in full before scanning those inside it, for similar reasons to that above... this avoids asking Windows to keep the file-find context for numerous directories at once if the code is executed on a very deep directory hierarchy. Either a stack or queue can be used (most easily, by using a TStringList as either), to get depth-first for breadth-first search behavior. (Of course, if you're only ever pointing it at a shallow hierarchy looking for DFM files, this is moot.) -- Kyle Cordes http://kylecordes.com __________________________________________________ Delphi-Talk mailing list -> Delphi-Talk@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk