aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/bfc/file/recursedir.h
blob: 2c40c7aca017b964f915baf1b2e2e0c191edfa8b (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
68
69
70
71
72
73
#ifndef _RECURSEDIR_H
#define _RECURSEDIR_H

#include <bfc/wasabi_std.h>
#include <bfc/ptrlist.h>
#include <bfc/common.h>
#include <bfc/file/readdir.h>

class ReadDir;

/**
  Read the contents of a directory, recursively.
  Also possible to use search match patterns.
  
  @short Recursive directory reading.
  @author Nullsoft
  @ver 1.0
  @see ReadDir
*/
class RecurseDir {
public:
  /**
    Sets the directory to read and the match pattern.
    If no match pattern is set, it will match against
    all files.
    
    @param path   The path of the directory to read.
    @param match  The match pattern to use.
  */
  RecurseDir(const wchar_t *path, const wchar_t *match=NULL);
  
  /**
    Deletes the directory stack.
  */
  ~RecurseDir();

  /**
    Advance to the next file.
    
    @ret 0, No more files to read; > 0, Files left to read.
  */
  int next();
  
  /**
    Restart from the top of the directory tree.
    
    @ret 0
  */
  int restart();

  /**
    Get the current directory path.
    
    @ret The path.
  */
  const wchar_t *getPath();
  
  /**
    Get the filename for the current file.
    
    @ret The filename.
  */
  const wchar_t *getFilename();

  const wchar_t *getOriginalPath();

private:
  StringW path, match;
  ReadDir *curdir;
  PtrList<ReadDir> dirstack;
};

#endif