Skip to content

Commit

Permalink
Optionally support Windows-style relative paths in playlists.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlindgren90 committed Aug 30, 2012
1 parent ddc7d84 commit c4f2b61
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/audacious/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ static const char * const core_defaults[] = {
"stop_after_current_song", "FALSE",

/* playlist */
#ifdef _WIN32
"convert_backslash", "TRUE",
#else
"convert_backslash", "FALSE",
#endif
"generic_title_format", "${?artist:${artist} - }${?album:${album} - }${title}",
"leading_zero", "FALSE",
"metadata_on_play", "FALSE",
Expand Down
4 changes: 3 additions & 1 deletion src/audacious/ui_preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ static PreferencesWidget playlist_page_widgets[] = {
.cfg_type = VALUE_BOOLEAN, .cname = "clear_playlist"},
{WIDGET_CHK_BTN, N_("Open files in a temporary playlist"),
.cfg_type = VALUE_BOOLEAN, .cname = "open_to_temporary"},
{WIDGET_LABEL, N_("<b>Metadata</b>"), NULL, NULL, NULL, FALSE},
{WIDGET_CHK_BTN, N_("Do not load metadata for songs until played"),
.cfg_type = VALUE_BOOLEAN, .cname = "metadata_on_play",
.callback = playlist_trigger_scan},
{WIDGET_LABEL, N_("<b>Compatibility</b>"), NULL, NULL, NULL, FALSE},
{WIDGET_CHK_BTN, N_("Interpret \\ (backward slash) as a folder delimiter"),
.cfg_type = VALUE_BOOLEAN, .cname = "convert_backslash"},
{WIDGET_TABLE, .data = {.table = {chardet_elements,
G_N_ELEMENTS (chardet_elements)}}}
};
Expand Down
16 changes: 14 additions & 2 deletions src/audacious/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,21 @@ char * construct_uri (const char * string, const char * playlist_name)
return NULL;

int pathlen = slash + 1 - playlist_name;
char buf[pathlen + 3 * strlen (string) + 1];
int rellen = strlen (string);

char buf[pathlen + 3 * rellen + 1];
memcpy (buf, playlist_name, pathlen);
str_encode_percent (string, -1, buf + pathlen);

if (get_bool (NULL, "convert_backslash"))
{
char tmp[rellen + 1];
strcpy (tmp, string);
string_replace_char (tmp, '\\', '/');
str_encode_percent (tmp, -1, buf + pathlen);
}
else
str_encode_percent (string, -1, buf + pathlen);

return strdup (buf);
}

Expand Down

0 comments on commit c4f2b61

Please sign in to comment.