From d2252afcd74af0248c6141c8086d03e12a0a316f Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 11 Oct 2011 00:47:18 -0700 Subject: Input class seems to be done. --- src/Handle.cc | 3 +++ src/Input.cc | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src') 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 #include #include #include @@ -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; } -- cgit v1.2.3