(2019-04-17, 19:40)Lunatixz Wrote: [ -> ]xbmcvfs.exist() has i/o penaltes too, BTW.
Why do you u need to stay in Kodi's VFS? you can use xbmc.translatePath() get the 'real path' then use os.isDir()
You can also test for file extension... I agree it would be nice to have isDir, isFile for Kodis VFS but for now there are workarounds.
Before Retroplayer, ROMs ZIP files or ISO images must be in a local filesystem because the external emulators (MAME, Retroarch) do not understand Kodi VFS al all. The situation has totally changed with Retroplayer, where some cores already support VFS. A feature long requested by many users is the ability to have ROMs and assets in Kodi VFS remotes, because most users have an HTPC computer with a small disk where Kodi installed and then a NAS to store media. When the user has both ROMs and assets in a remote I cannot use Python FS functions at all, only Kodi VFS.
In the Advanced Launchers I use isdir() to check for errors. If a user uses the Kodi GUI wizard to create the launchers, I can force xbmc.Dialog.browse() to return a directory when required. However, users with big collections may have as much as 50 launchers (SNES, NES, Game Boy, etc.) and using the wizard is not practical. For those, I created the XML configurations:
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<advanced_emulator_launcher_configuration>
<launcher>
<name>Atari 2600 (Retroarch)</name>
<category>Atari</category>
<Launcher_NFO>../Launcher assets Atari/Atari 2600.nfo</Launcher_NFO>
<platform>Atari 2600</platform>
<application>/home/kodi/bin/retroarch</application>
<args>-L /home/kodi/bin/libretro/stella_libretro.so -v -f "$rom$"</args>
<ROM_path>/home/kodi/AEL-ROMs/atari-2600/</ROM_path>
<ROM_ext>zip</ROM_ext>
<ROM_asset_path>/home/kodi/AEL-assets/atari-2600/</ROM_asset_path>
<Asset_Prefix>../Launcher assets Atari/Atari 2600</Asset_Prefix>
</launcher>
</advanced_emulator_launcher_configuration>
However, when using XML for importing launchers I have to check, for example, whether <ROM_path> is actually a directory or not and exists, and report "In Launcher XXXX ROM path YYYY is not a directory" or "In Launcher XXXX, directory YYYY not found", and more.
I agree with you, I can avoid using isdir()/isfile() at all, but that will make error reporting in the Advanced Launchers fuzzy and imprecise. Also, Kodi M**** master was just created and now it is time to propose new features and/or improvements
By the way ... xbmc.Dialog.browse() has the ability to distinguish between files and directories, and obviously works in local as well as remote filesystems. Hence, isdir()/isfile() just need to expose some functionality already known by the core.