diff options
author | Nicolas 'Pixel' Noble <pixel@nobis-crew.org> | 2013-01-20 19:09:14 -0800 |
---|---|---|
committer | Nicolas 'Pixel' Noble <pixel@nobis-crew.org> | 2013-01-20 19:09:14 -0800 |
commit | 76ab3f1ddc143d65e97ab301c742ad6553f1b560 (patch) | |
tree | 301510be8d9d96a1622bd9b0f43648dc74aa01df /src | |
parent | 78d9b284f1879725c071a348c0542c0ff31ab4da (diff) |
Adding open() as an operation to Input and Output.
Diffstat (limited to 'src')
-rw-r--r-- | src/Input.cc | 10 | ||||
-rw-r--r-- | src/Output.cc | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/Input.cc b/src/Input.cc index 5525932..2a89fa9 100644 --- a/src/Input.cc +++ b/src/Input.cc @@ -68,18 +68,20 @@ class AsyncOpStat : public Balau::AsyncOperation { }; -Balau::Input::Input(const char * fname) throw (GeneralException) { +Balau::Input::Input(const char * fname) { m_name.set("Input(%s)", fname); m_fname = fname; +} - Printer::elog(E_INPUT, "Opening file %s", fname); +void Balau::Input::open() throw (GeneralException) { + Printer::elog(E_INPUT, "Opening file %s", m_fname.to_charp()); cbResults_t cbResults; - createAsyncOp(new AsyncOpOpen(fname, &cbResults)); + createAsyncOp(new AsyncOpOpen(m_fname.to_charp(), &cbResults)); Task::operationYield(&cbResults.evt); if (cbResults.result < 0) { if (cbResults.errorno == ENOENT) { - throw ENoEnt(fname); + throw ENoEnt(m_fname); } else { char str[4096]; throw GeneralException(String("Unable to open file ") + m_name + " for reading: " + strerror_r(cbResults.errorno, str, sizeof(str)) + " (err#" + cbResults.errorno + ")"); diff --git a/src/Output.cc b/src/Output.cc index 1688ec7..7a50b03 100644 --- a/src/Output.cc +++ b/src/Output.cc @@ -69,18 +69,20 @@ class AsyncOpStat : public Balau::AsyncOperation { }; -Balau::Output::Output(const char * fname, bool truncate) throw (GeneralException) { +Balau::Output::Output(const char * fname) { m_name.set("Output(%s)", fname); m_fname = fname; +} - Printer::elog(E_OUTPUT, "Opening file %s", fname); +void Balau::Output::open(bool truncate) throw (GeneralException) { + Printer::elog(E_OUTPUT, "Opening file %s", m_fname.to_charp()); cbResults_t cbResults; - createAsyncOp(new AsyncOpOpen(fname, truncate, &cbResults)); + createAsyncOp(new AsyncOpOpen(m_fname.to_charp(), truncate, &cbResults)); Task::operationYield(&cbResults.evt); if (cbResults.result < 0) { if (cbResults.errorno == ENOENT) { - throw ENoEnt(fname); + throw ENoEnt(m_fname); } else { char str[4096]; throw GeneralException(String("Unable to open file ") + m_name + " for reading: " + strerror_r(cbResults.errorno, str, sizeof(str)) + " (err#" + cbResults.errorno + ")"); |