for the scol overmind
how to use core api/os3d string tools to get the name of a file, preceded by a forward slash, preceded by the next higher directory
full url: "http://ifam.net/openspace/spacemanshoot … ooter1.pak"
string we want to use as path to save file in cache: "dan_no_mohawk/spacemanshooter1.pak"
getUrlContentLenght "http://ifam.net/openspace/spacemanshooter17/dan_no_mohawk/spacemanshooter1.pak" @cbGetContentLength;
let "http://ifam.net/openspace/spacemanshooter17/dan_no_mohawk/spacemanshooter1.pak" -> urlsrc in
//get the name of the file, this is the 'lastpath'.
let getlastPathDir urlsrc -> destpathfile in
//split string into list of strings s r1, each of which is before, between, or after a "/"
let strToListSep urlsrc "/" -> urlist in
//get the second to last string, which is the folder in which the file is found
let nth_list urlist (sizelist urlist) - 2 ->secontolastdir in
//put file's folder together with / with file name
let strcatn secontolastdir::"/"::destpathfile::nil-> destpath in
this code produces the string: "dan_no_mohawk/spacemanshooter1.pak", which is the same string as lastpath, along with the name of the directory holding it.
]]>let strToListSep path "/" -< l in
let nth_list l (sizelist l) - 2 -< dir in
I was thinking in my uneducated mind something involving slicing up a string into a list thx.
]]>let "http://ifam.net/openspace/spacemanshooter17/dan_no_mohawk/spacemanshooter1.pak" -> urlsrc in
let getlastPathDir urlsrc -> destpathfile in
let getlastPathDir destpathfile -> download_directory in
let strcatn download_directory::"/"::destpathfile::nil-> destpath in
No ?
Why you write :
let getFilePathWithoutExt destpathfile -> download_directory in
let "http://ifam.net/openspace/spacemanshooter17/dan_no_mohawk/spacemanshooter1.pak" -> urlsrc in
let getlastPathDir urlsrc -> destpathfile in
let getFilePathWithoutExt destpathfile -> download_directory in
let strcatn download_directory::"/"::destpathfile::nil-> destpath in
will return:
spacemanshooter/spacemanshooter1.pak
which is ok, (the file saves to cache and loads in player) although how would I get a return value of "dan_no_mohawk" from the full url?
]]>there is tools for this in tools.pkg
getlastPathDir
Thx I'll get to work with that.
]]>How would I use the core or os3d api to take:
[url]http://ifam.net/openspace/hybridui3/mainwindow/mainwindow.pak[/url] mainwindow/mainwindow.pak
And return:
mainwindow/mainwindow.pak
You can tell me where to look in the tools directories and I should be able to figure it out
Thx