Appending to files
#1
Is there any way in xbmcvfs.File to append to a file, instead of just reading and writing. I want to write some data to the file (while downloading), close the file and then append new data to the file at a later stage.

Does anyone know if this is possible? I've also noticed that some examples of the File constructor have a third Boolean parameter:

Code:
f = xbmcvfs.File(path, 'w', True);

Does anyone know what that parameter does? It is not documented anywhere.
Reply
#2
that's an error in our documentation. it was recently fixed.

xbmcvfs.File() doesn't have an option to append data. you would need to handle that in your addon.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
Thanks ronie.

Is there a specific reason why there is no append function (or append open-mode)?

If you code this yourself, every time you append a file, you will have to copy the old file data to a new file. This is fine for small files, but if the file is 10GB this will create a huge overhead.
Reply
#4
For appending you should use standard Python open function which supports append mode.
Reply
#5
But Python does not natively support Samba or other network shares, or for that matter any of the other storage types that Kodi supports. So yes, for local files that would be fine, but any other files this will not work.
Reply

Logout Mark Read Team Forum Stats Members Help
Appending to files0