Use non-recursive way to traverse the directory and its subdirectory files

xiaoxiao2021-04-04  259

typedef BOOL (* PROCESS_FILE_FUNCTION) (LPCTSTR filename); above PROCESS_FILE_FUNCTION is a function pointer, the function processing file called filename, if the function returns FALSE, the ProcessDirectory quit immediately, look no further void ProcessDirectory (LPCTSTR dirname , PROCESS_FILE_FUNCTION PROC) {CStringArray Dirs; CString Searchname; cfileFind Find; DIRS.ADD (DIRNAME); BOOL BRET; While (DIRS.GETSIZE ()> 0) {searchname = DIRS [0] "//*.*"; DIRS.Removeat (0); Bret = find.findfile (searchname, 0); if (! BRET) Continue; Do {Bret = Find.FindNextFile (); if (Find.isdots ()) {// ignore. .} {DIRS.ADD ()) {DIRS.ADD (Find.GetFilePath ()); Continue;} else {if (! Proc (Find.getFilePath ())) {return;}}} while Bret);}}

转载请注明原文地址:https://www.9cbs.com/read-131725.html

New Post(0)