diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-19 16:38:56 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2012-05-19 16:38:56 +0200 |
commit | d502fce7d4db492690e39c72fc029aa05a65057d (patch) | |
tree | a5797a97212fff8142dc7f61792facca07c904eb /src/user/lib/fwik/io/Dir.cpp | |
parent | 8e07c1db6ba4bedd0f8fe537a6fb0ca80e5d25f4 (diff) | |
download | TCE-d502fce7d4db492690e39c72fc029aa05a65057d.tar.gz TCE-d502fce7d4db492690e39c72fc029aa05a65057d.zip |
More improvements in FWIK - more strings, Dir class, ...
Diffstat (limited to 'src/user/lib/fwik/io/Dir.cpp')
-rw-r--r-- | src/user/lib/fwik/io/Dir.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/user/lib/fwik/io/Dir.cpp b/src/user/lib/fwik/io/Dir.cpp new file mode 100644 index 0000000..cfcc77b --- /dev/null +++ b/src/user/lib/fwik/io/Dir.cpp @@ -0,0 +1,37 @@ +#include <IO/Dir.h> + +Dir::Dir(const Node &n) : Node(n) { + _init(); +} + +Dir::Dir(FILE f) : Node(f) { + _init(); + if (error == E_INVALID_TYPE) libc::close(fd); +} + +Dir::Dir(const char* filename, int mode) : Node(filename, mode) { + _init(); + if (error == E_INVALID_TYPE) libc::close(fd); +} + +void Dir::_init() { + if (error < 0) return; + pos = 0; + if ((info.type & FT_DIR) == 0) { + error = E_INVALID_TYPE; + } +} + +Dir::~Dir() { +} + +String Dir::read_ent() { + char buf[256]; + int l = libc::read(fd, pos, 256, buf); + if (l > 0) { + pos++; + return String(buf, l); + } else { + return ""; + } +} |