1 #include "unifilesystemgen.h"
4 #include "wvfileutils.h"
6 #include "wvlinkerhack.h"
23 UniFileSystemGen::UniFileSystemGen(WvStringParm _dir, mode_t _mode)
24 : dir(_dir), mode(_mode)
32 for (i.rewind(); i.next(); )
34 if (*i ==
"." || *i ==
".." || *i ==
"")
54 WvFile file(path, O_RDONLY);
59 if (fstat(file.
getrfd(), &st) < 0)
62 if (S_ISREG(st.st_mode))
91 WvFile file(path, O_WRONLY|O_CREAT|O_TRUNC, mode & 0666);
113 : gen(_gen), i(path,
false), rel(_rel)
126 {
return i->relname; }
129 {
return gen->
get(
WvString(
"%s/%s", rel, i->relname)); }
bool next()
Seeks to the next element in the sequence.
virtual size_t write(const void *buf, size_t count)
Write data to the stream.
virtual int geterr() const
If isok() is false, return the system error number corresponding to the error, -1 for a special error...
virtual bool isok() const
return true if the stream is actually usable right now
UniConfKey removelast(int n=1) const
Returns the path formed by removing the last n segments of this path.
WvFile implements a stream connected to a file or Unix device.
WvString getstr()
Returns the entire buffer as a null-terminated WvString.
int getrfd() const
Returns the Unix file descriptor for reading from this stream.
WvString is an implementation of a simple and efficient printable-string class.
An abstract data container that backs a UniConf tree.
virtual void set(const UniConfKey &key, WvStringParm value)
Stores a string value for a key into the registry.
An iterator over the segments of a key.
virtual void setv(const UniConfPairList &pairs)
Stores multiple key-value pairs into the registry.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
virtual size_t read(void *buf, size_t count)
read a data block on the stream.
virtual WvString get(const UniConfKey &key)
Fetches a string value for a key from the registry.
virtual Iter * iterator(const UniConfKey &key)
Returns an iterator over the children of the specified key.
void rewind()
Rewinds the iterator.
UniConfKey key() const
Returns the current key.
WvString value() const
Returns the value of the current key.
Creates a UniConf tree that mirrors some point in the Linux filesystem, with restrictions.
An abstract iterator over keys and values in a generator.