Пример #1
0
static char * str_get_decoded (char * str)
{
    if (! str)
        return NULL;

    str_decode_percent (str, -1, str);
    return str_get (str);
}
Пример #2
0
static bool_t read_key (ReadState * state, char * * keyp, char * * valp)
{
    if (! read_key_raw (state, keyp, valp))
        return FALSE;

    if (strcmp (* keyp, "uri"))
        str_decode_percent (* valp, -1, * valp);

    return TRUE;
}
Пример #3
0
EXPORT char * uri_to_display (const char * uri)
{
    if (! strncmp (uri, "cdda://?", 8))
        return g_strdup_printf (_("Audio CD, track %s"), uri + 8);

    char buf[strlen (uri) + 1];

#ifdef _WIN32
    if (! strncmp (uri, "file:///", 8))
    {
        str_decode_percent (uri + 8, -1, buf);
        string_replace_char (buf, '/', '\\');
    }
#else
    if (! strncmp (uri, "file://", 7))
        str_decode_percent (uri + 7, -1, buf);
#endif
    else
        str_decode_percent (uri, -1, buf);

    return g_strdup (buf);
}
Пример #4
0
EXPORT char * uri_to_filename (const char * uri)
{
#ifdef _WIN32
    g_return_val_if_fail (! strncmp (uri, "file:///", 8), NULL);
    char buf[strlen (uri + 8) + 1];
    str_decode_percent (uri + 8, -1, buf);
#else
    g_return_val_if_fail (! strncmp (uri, "file://", 7), NULL);
    char buf[strlen (uri + 7) + 1];
    str_decode_percent (uri + 7, -1, buf);
#endif
#ifdef _WIN32
    string_replace_char (buf, '/', '\\');
#endif

    char * name = g_locale_from_utf8 (buf, -1, NULL, NULL, NULL);
    if (! name)
    {
        const char * locale = setlocale (LC_ALL, NULL);
        fprintf (stderr, "Cannot convert filename to system locale (%s): %s\n", locale, buf);
    }

    return name;
}