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/Input.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/Input.cc') 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