/usr/include/wvstreams/wvdiriter.h is in libwvstreams-dev 4.6.1-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 74 75 76 77 78 79 80 81 82 83 84 85 86 | /* -*- Mode: C++ -*-
* Worldvisions Weaver Software:
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
*
* Directory iterator. Recursively uses opendir and readdir, so you don't
* have to. Basically implements 'find'.
*
*/
#ifndef __WVDIRITER_H
#define __WVDIRITER_H
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "wvstring.h"
#include "wvlinklist.h"
#include "strutils.h"
struct WvDirEnt : public stat
/***************************/
{
// we already have everything from struct stat, but let's also include
// some variations on the filename for convenience.
WvString fullname; // contains: startdir/path/file
WvString name; // contains: file
WvString relname; // contains: path/file
};
class WvDirIter
/*************/
{
private:
bool recurse;
bool go_up;
bool skip_mounts;
bool found_top;
WvDirEnt topdir;
WvDirEnt info;
WvString relpath;
struct Dir {
Dir( DIR * _d, WvString _dirname )
: d( _d ), dirname( _dirname )
{}
~Dir()
{ if( d ) closedir( d ); }
DIR * d;
WvString dirname;
};
DeclareWvList( Dir );
DirList dirs;
DirList::Iter dir;
public:
// the sizeof(stat) helps an assert() in wvdiriter.cc.
WvDirIter( WvStringParm dirname,
bool _recurse = true, bool _skip_mounts = false,
size_t sizeof_stat = sizeof(struct stat) );
~WvDirIter();
bool isok() const;
bool isdir() const;
void rewind();
bool next();
// calling up() will abandon the current level of recursion, if, for
// example, you decide you don't want to continue reading the contents
// of the directory you're in. After up(), next() will return the next
// entry after the directory you've abandoned, in its parent.
void up()
{ go_up = true; }
const WvDirEnt *ptr() const { return &info; }
WvIterStuff(const WvDirEnt);
int depth() const
{ return( dirs.count() ); }
};
#endif
|