diff options
| author | geronimo <geronimo013@gmx.de> | 2012-07-30 09:12:30 +0200 |
|---|---|---|
| committer | geronimo <geronimo013@gmx.de> | 2012-07-30 09:12:30 +0200 |
| commit | 2331befb330683d0e5459f9ca2d522f2f06c3d7e (patch) | |
| tree | e95c3c4e40d57cbcf6af16d2736f34dce0279c4b /libs/IO/src/FileReader.cc | |
| parent | 570a18b0d0a9a00b240504ac949214d6cc96949b (diff) | |
| download | cmp-2331befb330683d0e5459f9ca2d522f2f06c3d7e.tar.gz cmp-2331befb330683d0e5459f9ca2d522f2f06c3d7e.tar.bz2 | |
worked out commandreader
Diffstat (limited to 'libs/IO/src/FileReader.cc')
| -rw-r--r-- | libs/IO/src/FileReader.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libs/IO/src/FileReader.cc b/libs/IO/src/FileReader.cc index 519c749..fd692ca 100644 --- a/libs/IO/src/FileReader.cc +++ b/libs/IO/src/FileReader.cc @@ -29,13 +29,18 @@ #include <unistd.h> cFileReader::cFileReader(cFile *Input) - : fd(-1) - , file(Input) + : file(Input) +{ + Open(); +} + +bool cFileReader::Open() { if (file && file->Exists() && file->CanRead()) { fd = open(file->AbsolutePath(), O_RDONLY); if (fd < 0) esyslog("ERROR: could not open %s", file->AbsolutePath()); } + return fd > 0; } cFileReader::~cFileReader() @@ -45,7 +50,7 @@ cFileReader::~cFileReader() void cFileReader::Close() { - if (fd >= 0) { + if (fd > 0) { close(fd); fd = -1; } @@ -54,10 +59,3 @@ void cFileReader::Close() file = NULL; } } - -int cFileReader::Read(char* buf, int bufSize) -{ - if (fd >= 0) return read(fd, buf, bufSize); - esyslog("ERROR: not an open file! %s", file->AbsolutePath()); - return 0; -} |
