special:// paths and translatePath
#1
There are people having issues with the svn repo trying to install items.

i have not changed anything, so on windows i would install to translatePath("U:\\"...).

should this be the folder xbmc was installed to. it is installing items there, whether using -p or not. are we now suppose to use the special:// folders and eliminate translatePath.

will you post a list of these special:// folders so everyone can see.

there shoulod be only one path for scripters to use for things like this. it should be transparent to the scripter. like U:\\ was.

thanks
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#2
you should use the special paths. the translatepath() should only be done when you need the actual real path for stuff (say, you want to pass it to the os). it should NEVER be done on saved paths.

for the technically inclined see, CSpecialProtocol::TranslatePath() for an up to date list. for the rest a list of the most important ones in this context;
Code:
special://profile/ - P:\
special://masterprofile/ - T:\
special://home/ - U:\
special://xbmc/ - Q:\
Reply
#3
so how should a path mapping, such as the following, be done properly ?

DIR_USERDATA = os.path.join( "T:"+os.sep,"script_data", __scriptname__ )

would it be:

DIR_USERDATA = os.path.join( "special://masterprofile/", "script_data", __scriptname__ )

if that is the case, should the it also use os.sep making it more platform portable?

ie.
DIR_USERDATA = os.path.join( "special:" + os.sep + "masterprofile", "script_data", __scriptname__ )


I've only noticed this with T: drive myself so far. and not on xbox, just windows. Is this 'new' behaviour being merged back to xbox ?

cheers
BBB
Retired from Add-on dev
Reply
#4
yeah, it is being merged back.

your example is correct, but you would NEVER use a \, it is always /. i.e. in your case

special://masterprofile/script_data/scriptname/
Reply
#5
so is using a / instead of os.sep is enough to make it work an all platforms ?

DIR_USERDATA = os.path.join( "special://masterprofile/", "script_data", __scriptname__ )

and if doing a cmd such as os.listdir() then it should go throu translatePath() too ?

ie.
os.listdir(xbmc.translatepath(DIR_USERDATA))
Retired from Add-on dev
Reply
#6
i don't think you want to use os.path.join() as that would insert a \ on windows/xbox

"/".join([ "special://masterprofile", "script_data", __scriptname__ ])
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#7
yes it does insert \ and presumably / on linux - but is that a bad thing as it does resolve the path correctly (only tested on windows for now)

ie.
DIR_USERDATA = os.path.join( "special://masterprofile","script_data", __scriptname__ )

becomes

DIR_USERDATA=special://masterprofile\script_data\myscriptname

which I now push throu xbmc.translatePath(USERDATA) when I do any os.path commands.

i thought the whole idea was to use os.path inorder to make correctly formed path strings for that platform ?

BBB
Retired from Add-on dev
Reply
#8
xbmc.translatePath("special://home/")

no matter if i launch with -p or not, is always "F:\source\XBMC-Linux" on windows.

is this correct? seems wrong
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#9
BBB, it is always a url address now.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#10
any chance of changing xbmc.TranslatePath() to 'fix' incorrect separators from os.path.join?

using '/'.join() makes sense once you realize it is always a url, but at first it is extremely unintuitive compared to os.path.join()
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#11
special:://home/ is wrong on windows 7/vista 64bit.

i can't see if there is a special case for WIN64 for vista, but there may need to be one similar to linux. as i guess the items should go in the roaming folder?

edit: which according to environment variables it is APPDATA which equals c:\Users\Scott\AppData\Roaming
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#12
a sticky with examples explaining all this seems a good idea.

if url / is now the way to build a path across all platforms, can you see any reason not to just concat using simple string + now ?
ie.
DIR_USERDATA = "special://masterprofile/script_data/" + __scriptname__
Retired from Add-on dev
Reply
#13
i see where home is set for windows. it has a fixme note, so if i can figure out how to get an env variable value, use that there. APPDATA exists on xp and vista
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#14
this appears to be what is needed.

with -p it save special://home/ to the same directory as the exe

without it save to the roaming folder

Code:
Index: Application.cpp
===================================================================
--- Application.cpp (revision 17591)
+++ Application.cpp (working copy)
@@ -1132,13 +1132,13 @@
     else
       strWin32UserFolder = strExecutablePath;

-    // FIXME: The Home path should be assumed writeable, which won't be the case if installed to C:\Program Files
-    CSpecialProtocol::SetHomePath(strExecutablePath);
-
     // create user/app data/XBMC
     CStdString strPath = CUtil::AddFileToFolder(strWin32UserFolder,"XBMC");
     CDirectory::Create(strPath);

+    // FIXME: The Home path should be assumed writeable, which won't be the case if installed to C:\Program Files
+    CSpecialProtocol::SetHomePath(strPath);
+
     // move log to platform dirs
     g_stSettings.m_logFolder = strPath;
     CUtil::AddSlashAtEnd(g_stSettings.m_logFolder);
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#15
in order to ease the transition of all scripts rather than the majority needing fixing, what about having translatePath() convert old mappings to the new special:// equiv?
Retired from Add-on dev
Reply

Logout Mark Read Team Forum Stats Members Help
special:// paths and translatePath0