1 #ifdef BUILDING_ECERE_COM
6 public import static "ecere"
12 public class NormalFileSystemIterator : FileSystemIterator
15 Array<StackFrame> stack { };
18 property const char * extensions { set { delete extensions; if(value) extensions = CopyString(value); } }
20 ~NormalFileSystemIterator()
25 void Iterate(const char * startPath)
29 if(!OnInit(startPath))
32 frame = StackFrame { };
34 frame.path = CopyString(startPath);
35 frame.listing = FileListing { startPath, extensions = extensions }; // there should be a sorted = true/false
39 FileAttribs attribs = FileExists(startPath);
40 // || attribs.isCDROM || attribs.isRemote || attribs.isRemovable || attribs.isServer || attribs.isShare || attribs.isSystem || attribs.isTemporary
43 else if(attribs.isDirectory)
45 else if(attribs.isFile)
51 if(frame.listing.Find())
53 bool peek = frame.listing.stats.attribs.isDirectory && OnFolder(frame.listing.path);
54 if(!frame.listing.stats.attribs.isDirectory)
56 const char * path = frame.listing.path;
61 StackFrame newFrame { };
63 newFrame.path = CopyString(frame.listing.path);
64 newFrame.listing = FileListing { newFrame.path, extensions = frame.listing.extensions };
70 StackFrame parentFrame = stack.count > 1 ? stack[stack.count - 2] : null;
71 OutFolder(parentFrame ? parentFrame.listing.path : startPath, !parentFrame);
72 stack.lastIterator.Remove();
75 frame = stack.lastIterator.data;
83 public class FileSystemIterator
86 bool iterateStartPath;
88 virtual bool OnInit(const char * startPath)
93 virtual bool OnFile(const char * filePath)
98 virtual bool OnFolder(const char * folderPath)
103 virtual bool OnVolume(const char * volumePath)
108 virtual void OutFolder(const char * folderPath, bool isRoot)
113 static class IteratorThread : Thread
117 //listing = FileListing { dir, extensions = filter.extensions }; // there should be a sorted = true/false
121 public class StackFrame