add slash at end - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: add slash at end (/showthread.php?tid=115263) |
add slash at end - Martijn - 2011-11-22 In this commit there is an internal util used for adding a slash at the end. https://github.com/xbmc/xbmc/commit/9a5fd4250d25723340104a8df89d6242262c00bc Is this also available for add-ons (python)? - spiff - 2011-11-22 nope. but python has its own. - Martijn - 2011-11-22 spiff Wrote:nope. but python has its own. and could you by any chance enlighten me on that - giftie - 2011-11-23 Machine-Sanctum Wrote:and could you by any chance enlighten me on that you can always use, os.path.join( path, "" ) will add the proper file slash based on the OS. - paddycarey - 2011-11-24 giftie Wrote:you can always use, os.path.join( path, "" ) will add the proper file slash based on the OS. os.path.join works for the most part but where it falls down is when trying to work with smb:// or nfs:// paths on windows. It detects the OS as Windows and so uses \ when / would be correct for the path. At the moment we have to test if the path contains :// and if it does set the separator to /. Not pretty but it works. - giftie - 2011-11-25 paddycarey Wrote:os.path.join works for the most part but where it falls down is when trying to work with smb:// or nfs:// paths on windows. It detects the OS as Windows and so uses \ when / would be correct for the path. I know python autocorrects the separators and I thought XBMC also does(I could be wrong, but the source code it does look like it does) With that being said, it is easy to correct the slashes after an os.path.join(). Code: if ( len( path ) > 1 and path[1] == ":" ) or ( len( path ) > 1 and path[0] == "\\" and path[1] == "\\" ): # tests to see if is a DOS path or a windows share this is python version of what I found in the XBMC source code(URIUtils.cpp) - FrostBox - 2011-11-25 Hi, I use this in my all add-ons and work perfectly PHP Code: # normalize the path (win32 support / as path separators) and make sure endswith by / - Martijn - 2011-11-26 The problem is not in copy/deleting of files but in the caching of images and the way skins formulate the path. They always use '/' at the end of a path. So this will present a problem with win32 folder structures because the last slash of a movie path must be a '/' (and some skinners even create a '//'at the end). So this path: Code: Z:\Films\Algemeen\Batman Begins (2005) Code: Z:\Films\Algemeen\Batman Begins (2005)/fanart.jpg or some one must know an easier way to overcome the caching problem like discussed in: http://forum.xbmc.org/showthread.php?tid=104857 - FrostBox - 2011-11-26 Maybe with this http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmc.html#-validatePath PHP Code: validatePath(...) - Martijn - 2011-11-27 FrostBox Wrote:Maybe with thisYeah I also tried that. The real problem is that skinners cannot always have a universal way of using paths and they are not all doing it the same way. So at the moment we have to anticipate that to replace the cached version of an image with a new one. Or else it won't be visible at once. Did find something although i'm not really sure what it does: http://passion-xbmc.org/addons/?Page=View&ID=script.ImageCacher and http://mirrors.xbmc.org/addons/eden-pre/script.common.plugin.cache/ |