open-source-search-engine/Dir.h

56 lines
1.2 KiB
C
Raw Normal View History

2013-08-03 00:12:24 +04:00
#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
long long getUsedSpace ( );
char *getNewFilename ( char *pattern ) ;
long long getNewId ( char *pattern ) ;
long long 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;
2013-08-03 00:12:24 +04:00
};
#endif