I don't think this function is correct now... I think it should be:
```
	MCAutoStringRef t_path_str;
	if (strrchr(p_path, '/') != nil)
	{
                MCAutoStringRef t_original_path;
                /* UNCHECKED */ MCStringCreateWithCString(p_path, &t_original_path)
		if (*p_path != '/')
			MCS_resolvepath(t_original_path, &t_path_str);
		else
		        t_path_str = t_original_path;
	}
	
	char *t_folder;
	t_folder = nil;
        if (MCS_exists(*t_path_str, false))
		/* UNCHECKED */ t_folder = strdup(MCStringGetCString(*t_path_str));
	else
        {
                uindex_t t_index;
                if (MCStringLastIndexOfLastChar(*t_path_str, '/', kMCStringCompareExact, UINDEX_MAX, t_index))
                {
                    MCAutoStringRef t_folder_str;
                    /* UNCHECKED */ MCStringCopySubstring(*t_path_str, MCRangeMake(0, t_index), &t_folder_str);
                    t_folder = strdup(MCStringGetCString(*t_folder_str));
                }
	}
	
	return t_folder;	
```