Questions on the new KIO::FileJob API
Allan Sandfeld Jensen
kde at carewolf.com
Wed May 14 20:02:27 BST 2008
On Wednesday 07 May 2008, Vlad wrote:
> Hi,
>
> --- nf2 <nf2 at scheinwelt.at> wrote:
> > 1) - Creating Files: Apparently FileJob in kio_file doesn't allow
> > creating files.
>
> I think this bug is fixed by adding O_CREAT whenever the user requests
> QIODevice::WriteOnly. If the file already exists, O_CREAT does
> nothing, so it shouldn't hurt. I hope to commit this fix soon:
>
> http://lists.kde.org/?l=kde-core-devel&m=121012416913922&w=2
>
Sounds like a good idea.
> > 2) - Reading Files: From reading the code in kio_file i'm not sure
> > whether data() is supposed to emit all the requested data in a
> > single
> > callback
>
> Yes, one data() should emit all the requested data, unless the slave
> reaches EOF, in which case it returns all the data up to the EOF.
>
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.
> > as the client might try to call
> > seek()
> > before read() is finished.
>
> Once you call FileJob::read(), you're supposed to _wait_ until the
> data() slot from that read() request has been served before making
> another request to the FileJob (ie. calling another FileJob::seek(),
> FileJob::write(), etc).
>
No. The calls to FileJob queues, so there is no reason to wait, but remember
seek will _not_ cancel already issued reads. It will wait for previous
actions to complete then perform the seek. If you use the API for streaming
it is recommended you issue a stream of read(blocksize) to fill a local
buffer, and when seeking clearing the local buffer. You receive a position()
signal to signify a succesfull seek.
Regards
`Allan
More information about the kde-core-devel
mailing list