Array<StackFrame> stack { };
char * extensions;
- property char * extensions { set { delete extensions; if(value) extensions = CopyString(value); } }
+ property const char * extensions { set { delete extensions; if(value) extensions = CopyString(value); } }
~NormalFileSystemIterator()
{
delete extensions;
}
- void Iterate(char * startPath)
+ void Iterate(const char * startPath)
{
StackFrame frame;
- if(OnInit(startPath))
- {
- frame = stack.firstIterator.data;
- }
- else
- {
- frame = StackFrame { };
- stack.Add(frame);
- frame.path = CopyString(startPath);
- frame.listing = FileListing { startPath, extensions = extensions }; // there should be a sorted = true/false
- }
+ if(!OnInit(startPath))
+ return;
+
+ frame = StackFrame { };
+ stack.Add(frame);
+ frame.path = CopyString(startPath);
+ frame.listing = FileListing { startPath, extensions = extensions }; // there should be a sorted = true/false
if(iterateStartPath)
{
{
if(frame.listing.Find())
{
- char * name = frame.listing.name;
- bool isDirectory = frame.listing.stats.attribs.isDirectory;
bool peek = frame.listing.stats.attribs.isDirectory && OnFolder(frame.listing.path);
if(!frame.listing.stats.attribs.isDirectory)
{
- char * path = frame.listing.path;
- OnFile(frame.listing.path);
+ const char * path = frame.listing.path;
+ OnFile(path);
}
else if(peek)
{
StackFrame parentFrame = stack.count > 1 ? stack[stack.count - 2] : null;
OutFolder(parentFrame ? parentFrame.listing.path : startPath, !parentFrame);
stack.lastIterator.Remove();
+ delete frame;
if(stack.count)
frame = stack.lastIterator.data;
else
public:
bool iterateStartPath;
- virtual bool OnInit(char * startPath)
+ virtual bool OnInit(const char * startPath)
{
- return false;
+ return true;
}
- virtual bool OnFile(char * filePath)
+ virtual bool OnFile(const char * filePath)
{
return true;
}
- virtual bool OnFolder(char * folderPath)
+ virtual bool OnFolder(const char * folderPath)
{
return true;
}
- virtual bool OnVolume(char * volumePath)
+ virtual bool OnVolume(const char * volumePath)
{
return true;
}
- virtual void OutFolder(char * folderPath, bool isRoot)
+ virtual void OutFolder(const char * folderPath, bool isRoot)
{
}
}
-
+/*
static class IteratorThread : Thread
{
void Temp()
//listing = FileListing { dir, extensions = filter.extensions }; // there should be a sorted = true/false
}
}
-
+*/
public class StackFrame
{
int tag;
//delete listing;
}
};
-