summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/ReadJob.h1
-rw-r--r--lib/ReadJob.cc15
2 files changed, 13 insertions, 3 deletions
diff --git a/include/ReadJob.h b/include/ReadJob.h
index fb2fa32..c7843d5 100644
--- a/include/ReadJob.h
+++ b/include/ReadJob.h
@@ -34,6 +34,7 @@ class ReadJob : public Task {
private:
Handle * s, * d;
const Regex * regex;
+ String buff;
};
#endif
diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc
index 6851f0e..33f78dd 100644
--- a/lib/ReadJob.cc
+++ b/lib/ReadJob.cc
@@ -34,22 +34,31 @@ ReadJob::ReadJob(Handle * as, Handle * ad, const Regex & aregex) : s(as), d(ad),
ReadJob::~ReadJob() { }
int ReadJob::Do() throw (GeneralException) {
- String buff;
-
+ String ubuff;
+
switch (current) {
case 0:
try {
- *s >> buff;
+ if (buff.strlen() == 0) {
+ *s >> buff;
+ } else {
+ *s >> ubuff;
+ }
}
catch (IOAgain e) {
+ if (ubuff.strlen() != 0)
+ buff = buff + ubuff;
WaitFor(s, W4_READING);
Suspend(TASK_ON_HOLD);
}
+ if (ubuff.strlen() != 0)
+ buff = buff + ubuff;
case 1:
try {
*d << buff << "\n";
}
catch (IOAgain e) {
+ /***TODO*** Potential bug here: if the write was partial, we'd need to restart at a later position. */
current = 1;
WaitFor(d, W4_WRITING);
Suspend(TASK_ON_HOLD);