aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/bfc/file/recursedir.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/bfc/file/recursedir.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Wasabi/bfc/file/recursedir.cpp')
-rw-r--r--Src/Wasabi/bfc/file/recursedir.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/Src/Wasabi/bfc/file/recursedir.cpp b/Src/Wasabi/bfc/file/recursedir.cpp
new file mode 100644
index 00000000..ca836a28
--- /dev/null
+++ b/Src/Wasabi/bfc/file/recursedir.cpp
@@ -0,0 +1,67 @@
+#include "precomp_wasabi_bfc.h"
+#include "recursedir.h"
+
+RecurseDir::RecurseDir( const wchar_t *_path, const wchar_t *_match ) :
+ path( _path ), match( _match )
+{
+ if ( match.isempty() ) match = Wasabi::Std::matchAllFiles();
+
+ curdir = new ReadDir( path, match );
+}
+
+RecurseDir::~RecurseDir()
+{
+ dirstack.deleteAll();
+}
+
+int RecurseDir::next()
+{
+ for ( ;;)
+ {
+ if ( curdir == NULL )
+ { // pop one off the stack
+ curdir = dirstack.getLast();
+ if ( curdir == NULL ) return 0; // done
+ dirstack.removeLastItem();
+ }
+ int r = curdir->next();
+ if ( r <= 0 )
+ {
+ delete curdir; curdir = NULL;
+ continue; // get another one
+ }
+
+ // ok, we have a file to look at
+ if ( curdir->isDir() )
+ { // descend into it
+ StringW newpath = curdir->getPath();
+ newpath.AppendPath( curdir->getFilename() );
+
+ dirstack.addItem( curdir ); // push the old one
+ curdir = new ReadDir( newpath, match ); // start new one
+
+ continue;
+ }
+
+ return r;
+ }
+}
+
+const wchar_t *RecurseDir::getPath()
+{
+ if ( curdir == NULL )
+ return NULL;
+ return curdir->getPath();
+}
+
+const wchar_t *RecurseDir::getFilename()
+{
+ if ( curdir == NULL )
+ return NULL;
+ return curdir->getFilename();
+}
+
+const wchar_t *RecurseDir::getOriginalPath()
+{
+ return path;
+}