Questions on the new KIO::FileJob API

Vlad vladc6 at
Sun Jul 27 20:58:00 BST 2008


--- On Sun, 7/27/08, Allan Sandfeld Jensen <kde at> wrote:
> > > No. A read can result in any number data() emits.
> For files
> > > it will usually be
> > > only one, but for streams it can be multiple.
> >
> > Does FileJob::write() work the same way? In other
> words, do we have to
> > check whether bytes_written == the number of bytes
> sent, and if not, then
> > attempt again to write what is left over?
> >
> No you don't have to try again. It does the retries
> internally

This difference between FileJob::read() and FileJob::write() gets confusing. I suggest _not_ explicitly giving assurance that everything will be written at once, even though most KIO slaves will retry internally. It won't hurt client apps to check whether everything was indeed written and to prepare to write the leftover again if needed.

This way, the behaviors of FileJob::read() and FileJob::write() remain consistent with each other and with POSIX read() and write(), which don't guarantee atomicity either (see write_all() in kdelibs/kioslave/file/file.cpp).



More information about the kde-core-devel mailing list