[fpc-pascal] function to do common things to files a directory (possibly recursive)
leledumbo
leledumbo_cool at yahoo.co.id
Mon Mar 23 08:43:19 CET 2009
I often needed to delete files recursively (of course only those matched
given mask), so I create a program to help me doing it (Windows explorer's
search is SLOW and the deletion is even SLOWER!). However, the running time
is O(2n). Since I need to delete tens of thousands of files, the running
time is quite significant.
This can be achieved by a function that iterates over a directory (and
possibly its subdirectories) and do specified operation on every files that
matches given mask. However, I don't seem to find one. The closest one is
FindAllFiles from Lazarus' FileUtil unit + iteration of DeleteFile over the
result and that's the one I'm currently using. Would someone add it?
Possible interface:
type
TFileAction = procedure (const FileName: String);
procedure IterateDir(const BasePath,FileMask: String; const Recursive:
Boolean: Action: TFileAction);
P.S.: Attachment is the source code of my program.
http://www.nabble.com/file/p22655474/Deleter.pas Deleter.pas
--
View this message in context: http://www.nabble.com/function-to-do-common-things-to-files-a-directory-%28possibly-recursive%29-tp22655474p22655474.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
More information about the fpc-pascal
mailing list