1 #ifdef BUILDING_ECERE_COM
6 public import static "ecere"
12 public class NormalFileSystemIterator : FileSystemIterator
15 Array<StackFrame> stack { };
18 property char * extensions { set { delete extensions; if(value) extensions = CopyString(value); } }
20 ~NormalFileSystemIterator()
25 void Iterate(char * startPath)
31 frame = stack.firstIterator.data;
35 frame = StackFrame { };
37 frame.path = CopyString(startPath);
38 frame.listing = FileListing { startPath, extensions = extensions }; // there should be a sorted = true/false
43 FileAttribs attribs = FileExists(startPath);
44 // || attribs.isCDROM || attribs.isRemote || attribs.isRemovable || attribs.isServer || attribs.isShare || attribs.isSystem || attribs.isTemporary
47 else if(attribs.isDirectory)
49 else if(attribs.isFile)
55 if(frame.listing.Find())
57 char * name = frame.listing.name;
58 bool isDirectory = frame.listing.stats.attribs.isDirectory;
59 bool peek = frame.listing.stats.attribs.isDirectory && OnFolder(frame.listing.path);
60 if(!frame.listing.stats.attribs.isDirectory)
62 char * path = frame.listing.path;
63 OnFile(frame.listing.path);
67 StackFrame newFrame { };
69 newFrame.path = CopyString(frame.listing.path);
70 newFrame.listing = FileListing { newFrame.path, extensions = frame.listing.extensions };
76 StackFrame parentFrame = stack.count > 1 ? stack[stack.count - 2] : null;
77 OutFolder(parentFrame ? parentFrame.listing.path : startPath, !parentFrame);
78 stack.lastIterator.Remove();
80 frame = stack.lastIterator.data;
88 public class FileSystemIterator
91 bool iterateStartPath;
93 virtual bool OnInit(char * startPath)
98 virtual bool OnFile(char * filePath)
103 virtual bool OnFolder(char * folderPath)
108 virtual bool OnVolume(char * volumePath)
113 virtual void OutFolder(char * folderPath, bool isRoot)
118 static class IteratorThread : Thread
122 //listing = FileListing { dir, extensions = filter.extensions }; // there should be a sorted = true/false
126 public class StackFrame