Thread: MAKI Cheats
View Single Post
Old 24th February 2016, 00:15   #910
Plague
f(caffeine){
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));
                break;
            }
            else
                
i--;
        }
    }

    return 
parentpath;

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
messagebox(parentpath"test"0""); 
Plague is offline   Reply With Quote