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)
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 bool peek = frame.listing.stats.attribs.isDirectory && OnFolder(frame.listing.path);
58 if(!frame.listing.stats.attribs.isDirectory)
60 const char * path = frame.listing.path;
65 StackFrame newFrame { };
67 newFrame.path = CopyString(frame.listing.path);
68 newFrame.listing = FileListing { newFrame.path, extensions = frame.listing.extensions };
74 StackFrame parentFrame = stack.count > 1 ? stack[stack.count - 2] : null;
75 OutFolder(parentFrame ? parentFrame.listing.path : startPath, !parentFrame);
76 stack.lastIterator.Remove();
78 frame = stack.lastIterator.data;
86 public class FileSystemIterator
89 bool iterateStartPath;
91 virtual bool OnInit(const char * startPath)
96 virtual bool OnFile(const char * filePath)
101 virtual bool OnFolder(const char * folderPath)
106 virtual bool OnVolume(const char * volumePath)
111 virtual void OutFolder(const char * folderPath, bool isRoot)
116 static class IteratorThread : Thread
120 //listing = FileListing { dir, extensions = filter.extensions }; // there should be a sorted = true/false
124 public class StackFrame