00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __WVDIRITER_H
00011 #define __WVDIRITER_H
00012
00013 #include <dirent.h>
00014 #include <sys/stat.h>
00015 #include <sys/types.h>
00016
00017 #include "wvstring.h"
00018 #include "wvlinklist.h"
00019 #include "strutils.h"
00020
00021 struct WvDirEnt : public stat
00022
00023 {
00024
00025
00026 WvString fullname;
00027 WvString name;
00028 WvString relname;
00029 };
00030
00031 class WvDirIter
00032
00033 {
00034 private:
00035 bool recurse;
00036 bool go_up;
00037 bool skip_mounts;
00038 bool found_top;
00039
00040 WvDirEnt topdir;
00041 WvDirEnt info;
00042 WvString relpath;
00043
00044 struct Dir {
00045 Dir( DIR * _d, WvString _dirname )
00046 : d( _d ), dirname( _dirname )
00047 {}
00048 ~Dir()
00049 { if( d ) closedir( d ); }
00050
00051 DIR * d;
00052 WvString dirname;
00053 };
00054
00055 DeclareWvList( Dir );
00056 DirList dirs;
00057 DirList::Iter dir;
00058
00059 public:
00060
00061 WvDirIter( WvStringParm dirname,
00062 bool _recurse = true, bool _skip_mounts = false,
00063 size_t sizeof_stat = sizeof(struct stat) );
00064
00065 ~WvDirIter();
00066
00067 bool isok() const;
00068 bool isdir() const;
00069 void rewind();
00070 bool next();
00071
00072
00073
00074
00075
00076 void up()
00077 { go_up = true; }
00078
00079 const WvDirEnt *ptr() const { return &info; }
00080 WvIterStuff(const WvDirEnt);
00081
00082 int depth() const
00083 { return( dirs.count() ); }
00084 };
00085
00086 #endif