diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Handle.cc | 3 | ||||
-rw-r--r-- | src/Input.cc | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/Handle.cc b/src/Handle.cc index e00bcf2..7bb6c19 100644 --- a/src/Handle.cc +++ b/src/Handle.cc @@ -153,3 +153,6 @@ off_t Balau::SeekableHandle::wtell() throw (GeneralException) { return m_wOffset; } +bool Balau::SeekableHandle::isEOF() { + return m_rOffset == getSize(); +} diff --git a/src/Input.cc b/src/Input.cc index 09b2903..3fece65 100644 --- a/src/Input.cc +++ b/src/Input.cc @@ -1,3 +1,4 @@ +#include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> @@ -44,7 +45,11 @@ Balau::Input::Input(const char * fname) throw (GeneralException) : m_fd(-1), m_s Assert(cbResults.evt.gotSignal()); if (cbResults.result < 0) { char str[4096]; - throw GeneralException(String("Unable to open file ") + m_name + " for reading: " + strerror_r(cbResults.errorno, str, sizeof(str)) + " (err#" + cbResults.errorno + ")"); + if (cbResults.errorno == ENOENT) { + throw ENoEnt(fname); + } else { + throw GeneralException(String("Unable to open file ") + m_name + " for reading: " + strerror_r(cbResults.errorno, str, sizeof(str)) + " (err#" + cbResults.errorno + ")"); + } } else { m_fd = cbResults.result; } @@ -78,6 +83,21 @@ void Balau::Input::close() throw (GeneralException) { } } +ssize_t Balau::Input::read(void * buf, size_t count) throw (GeneralException) { + cbResults_t cbResults; + eio_req * r = eio_read(m_fd, buf, count, getROffset(), 0, eioDone, &cbResults); + Assert(r != 0); + Task::yield(&cbResults.evt); + Assert(cbResults.evt.gotSignal()); + if (cbResults.result > 0) { + rseek(cbResults.result, SEEK_CUR); + } else { + char str[4096]; + throw GeneralException(String("Unable to read file ") + m_name + ": " + strerror_r(cbResults.errorno, str, sizeof(str)) + " (err#" + cbResults.errorno + ")"); + } + return cbResults.result; +} + bool Balau::Input::isClosed() { return m_fd < 0; } |