Thread: MAKI Cheats
View Single Post
Old 23rd February 2016, 23:15   #910
return wasabi;
(Forum King)
Plague's Avatar
Join Date: Jul 2001
Location: Sweden
Posts: 3,984
Attempt #2: Local file path string handling in maki

Hmm, so it seems getToken doesn't handle multiple characters as token, which means my previous script may not always work.

There's also an easier way to get the full filepath without the "File:\\" part.
So, here's a better version, that I've also put into it's own function, for easier handling.
PHP Code:
String getParentFolderPath(String path) {
string parentpath "";
// we make sure the input path is not empty and that the second to last character is not a colon.
   // if the second to last character is a colon, it means the input is the root of the drive ( c:\ )
if (strlen(path) > && strmid(strright(path2), 01) != ":") {
// we must urlEncode the string, because we cannot search for a single backslash otherwise
path urlEncode(path);
int i strlen(path) - 1;
        while (
> -1) {
// search for the last backslash ( %5C ) position.
            // we urlDecode all text before that position.
            // the parentpath will then be that decoded text.
if (strsearch(strright(pathstrlen(path) - i), "%5C") > -1) {
parentpath urlDecode(strleft(pathi));


Here's how you use it:
You need to add the following line where you declare your global variables:
PHP Code:
Function String getParentFolderPath(String path); 
Then you can call the function wherever you want, like this:
PHP Code:
// get the complete path to the currently playing file.
string filepath getPath(getPlayItemMetaDataString("filename"));

// get the parent folder path.
string parentpath getParentFolderPath(filepath);

// this messagebox will show the parent folder path
Plague is offline   Reply With Quote