/* Given a pathname, return a string containing everything but the last component. NOTE: this overwrites the pathname handed into it....  */
char* get_dirname(char *path)
/* Given a pathname, return a string containing everything but the last component. NOTE: this overwrites the pathname handed into it....  */
char* get_dirname(char *path)
{
    char *separator;
    g_assert(path != NULL);
    separator = find_last_pathname_separator(path);
    if (separator == NULL) {
        return NULL;
    }
    *separator = '\0';
    return path;
}