From 2331befb330683d0e5459f9ca2d522f2f06c3d7e Mon Sep 17 00:00:00 2001 From: geronimo Date: Mon, 30 Jul 2012 09:12:30 +0200 Subject: worked out commandreader --- libs/IO/src/FileReader.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'libs/IO/src/FileReader.cc') 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 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; -} -- cgit v1.2.3