forked from gigablast/open-source-search-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dir.h
55 lines (36 loc) · 1.17 KB
/
Dir.h
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
#ifndef _DIR_H
#define _DIR_H
#include <sys/types.h> // for opendir
#include <dirent.h> // for opendir
#include "File.h" // for File::getFileSize()
class Dir {
public:
bool set ( char *dirName );
bool set ( char *d1 , char *d2 );
void reset ( );
bool open ( );
bool close ( );
void rewind ( ); // rewind to get the first filename
bool cleanOut ( ); // remove all files/dir in directory
bool create ( ); // create the directory
char *getNextFilename ( char *pattern = NULL );
// . calls getNextFilename and returns number of files matching the
// pattern
int getNumFiles ( char *pattern = NULL );
// . does not yet support recursion
int64_t getUsedSpace ( );
char *getNewFilename ( char *pattern ) ;
int64_t getNewId ( char *pattern ) ;
int64_t getFileId ( char *filename ) ;
char *getDir ( ) { return m_dirname; };
char *getDirName ( ) { return m_dirname; };
char *getDirname ( ) { return m_dirname; };
char *getFullName ( char *filename ); // prepends path
Dir ( );
~Dir ( );
private:
char *m_dirname;
DIR *m_dir;
bool m_needsClose;
};
#endif