Skip to content

Commit

Permalink
Add option to export playlists with relative paths (part 2).
Browse files Browse the repository at this point in the history
Currently only supported for .m3u and .pls playlists.
  • Loading branch information
jlindgren90 committed Sep 28, 2017
1 parent 56fd374 commit 6f752b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/m3u/m3u.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static char * split_line (char * line)
return feed + 1;
}

bool M3ULoader::load (const char * path, VFSFile & file, String & title,
bool M3ULoader::load (const char * filename, VFSFile & file, String & title,
Index<PlaylistAddItem> & items)
{
Index<char> text = file.read_all ();
Expand All @@ -77,7 +77,7 @@ bool M3ULoader::load (const char * path, VFSFile & file, String & title,

if (* parse && * parse != '#')
{
StringBuf s = uri_construct (parse, path);
StringBuf s = uri_construct (parse, filename);
if (s)
items.append (String (s));
}
Expand All @@ -88,12 +88,13 @@ bool M3ULoader::load (const char * path, VFSFile & file, String & title,
return true;
}

bool M3ULoader::save (const char * path, VFSFile & file, const char * title,
bool M3ULoader::save (const char * filename, VFSFile & file, const char * title,
const Index<PlaylistAddItem> & items)
{
for (auto & item : items)
{
StringBuf line = str_concat ({item.filename, "\n"});
StringBuf path = uri_deconstruct (item.filename, filename);
StringBuf line = str_concat ({path, "\n"});
if (file.fwrite (line, 1, line.len ()) != line.len ())
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions src/pls/pls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ bool PLSLoader::save (const char * filename, VFSFile & file, const char * title,

for (int count = 0; count < entries; count ++)
{
const char * uri = items[count].filename;
StringBuf local = uri_to_filename (uri);
StringBuf line = str_printf ("File%d=%s\n", 1 + count, local ? local : uri);
StringBuf path = uri_deconstruct (items[count].filename, filename);
StringBuf line = str_printf ("File%d=%s\n", 1 + count, (const char *) path);
if (file.fwrite (line, 1, line.len ()) != line.len ())
return false;
}
Expand Down

0 comments on commit 6f752b6

Please sign in to comment.