blob: ca836a28e097731f7153b84ee438ccf7cbfc5919 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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;
}
|