Questions on the new KIO::FileJob API

Vlad vladc6 at
Wed May 7 03:41:00 BST 2008


--- nf2 <nf2 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:

> 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.

> 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).

KioFuseApp::seekReadMainThread() in kiofuseapp.cpp does this:

Also, KIO is not threadsafe, so a FileJob can only be used by the
thread that it was created in.

> **) I wonder if there could be a "timeout" parameter for read() and 
> write(). GIO, for instance, seems to allow cancellation of 
> read()/write() operations.

That would be nice, but AFAIK apps that use KIO can't specify a
timeout value. However, the slave can have its own internal timer and
issue an error() if it detects that an operation is taking too long.

> 3) - Open ReadWrite doesn't seem to be implemented in kio_file

I think this is fixed by the series of patches referenced above.


Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

More information about the kde-core-devel mailing list