#include "CopyJob.h" #include "General.h" CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz) : s(as), d(ad), siz(asiz), cursiz(0), current(0) { } CopyJob::~CopyJob() { } int CopyJob::Do() { int r, tr; while (!s->IsClosed() || (siz != cursiz)) { if (!current) { tr = siz >= 0 ? siz - cursiz : COPY_BUFSIZ; try { r = s->read(buffer, MIN(COPY_BUFSIZ, tr)); } catch (IOAgain e) { return TASK_ON_HOLD; } current = 0; } try { d->write(buffer, r); } catch (IOAgain e) { current = 1; return TASK_ON_HOLD; } cursiz += r; } } String CopyJob::GetName() { return (String("CopyJob from ") + s->GetName() + " to " + d->GetName()); }