Kodi Community Forum

Full Version: Are there any advantages to using xbmcvfs?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am relatively new to ensuring cross-platform compatibility with file IO and I don't have all the platforms available to debug on.
I have been wondering if there are any advantages to using xbmcvfs over its native python os. equivalents.

Is there additional cross-platform compatibility built-in to these commands?
Is there any performance advantage?

Besides issues with chmod and access to directories on different platforms, are there any other common 'gotchas' that I need to plan for?

Thanks for any feedback.
python os only understands local filesystems, while xbmcvfs also works on remote filesystems (smb:// etc..)
Thanks, that's good to know. May I ask, do any of the more spartan systems (i.e. Rpi) use samba for any of the typical
Kodi directories, such as those returned by xbmc.translatePath('special:// .. ')?
no.
Actually it's possible (but rarely used) to move playlist video to a samba folder (I do) so in some rare case you might get a translated path with samba.
My approach to addons is to try to avoid to translatepath if possible and use xbmcvfs. if I really can't use xbmcvfs for some special access of the file I translate the path only at the very end without storing it.
yes, i answered the 'by default'. should have mentioned that.
You can safely use the os module unless you want to support the VFSs. Performance wise os module is a lot faster, but that should only relevant if you need to call those functions a lot. Only xbmcvfs 'gotcha' I can think of is the odd windows style api where slash at the end matters. For os.path there is dealing with unicode.
Thanks everyone for the very useful advice.

Happy Thanksgiving!