This bit gets rid of the characters after the last `/`. Use MCString* functions instead to build the appropriate substring.
Having a look at the whole function, `t_path` can actually be replaced with an `MCStringRef`, and you can use `MCStringCreateWithCFStringRef` to directly create the return value