Questions on the new KIO::FileJob API

nf2 nf2 at scheinwelt.at
Sat May 3 13:47:35 BST 2008


Hi,

As i'm trying to implement the FileJob in KIO-GioBridge i stumbled over 
a couple of open questions. By analyzing kio_file i'm not sure how this 
is supposed to work. I also wrote a new KIO unit-test "jobremotetest" 
which - along with put() and get() - tests the FileJob either in 
kio_file, or in other filesystems when specified in the Environment.

1) - Creating Files: Apparently FileJob in kio_file doesn't allow 
creating files. As there is no QIODevice::Create flag in the 
QIODevice::OpenMode enum, it should probably create the file on 
QIODevice::WriteOnly. Although i believe it would be good to have a 
QIODevice::Create flag which prevents overwriting by mistake. Please 
have a look at the GIO GFile API also...

http://library.gnome.org/devel/gio/stable/GFile.html

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, all the requested data in multiple callbacks *), or only as 
much as it can get (>1 bytes) **). The latter would allow to have a 
POSIX style streaming API, which has been missing in KIO anyway. This 
would also work the other way round - when writing - as the written() 
callback has a byte count.

*) this is what the current - kio_file implementation suggests, but i 
guess that's pretty dangerous, as the client might try to call seek() 
before read() is finished.

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

3) - Open ReadWrite doesn't seem to be implemented in kio_file - and 
it's not possible in GIO either. I wonder if it should. Probably it 
would work on filesystems like smb, sftp,...

Cheers,
Norbert






More information about the kde-core-devel mailing list