aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist_save.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-14 11:10:49 +0200
committerMax Kellermann <max@duempel.org>2008-10-14 11:10:49 +0200
commit5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6 (patch)
tree5fd2efeb95e3412ac177434611770ca864325c0e /src/playlist_save.c
parenta52a9fc1fc2b385dd66edd45f602ac337399cc83 (diff)
downloadmpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.tar.gz
mpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.tar.xz
mpd-5b71d5f6f707a35a7b7a47b33ef2e1417ea6bcc6.zip
mapper: new song-to-filesystem mapper library
The mapper library maps directory and song objects to file system paths. With this central library, the code mixture in path.c should be cleaned up, and we will be able to add neat features like aliasing.
Diffstat (limited to '')
-rw-r--r--src/playlist_save.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/playlist_save.c b/src/playlist_save.c
index 98979e2a2..55cd6bd87 100644
--- a/src/playlist_save.c
+++ b/src/playlist_save.c
@@ -19,21 +19,25 @@
#include "playlist_save.h"
#include "playlist.h"
#include "song.h"
+#include "mapper.h"
#include "path.h"
#include "ls.h"
+#include "database.h"
void
playlist_print_song(FILE *file, const struct song *song)
{
char tmp1[MPD_PATH_MAX], tmp2[MPD_PATH_MAX];
- song_get_url(song, tmp1);
- utf8_to_fs_charset(tmp2, tmp1);
-
- if (playlist_saveAbsolutePaths && song_is_file(song))
- fprintf(file, "%s\n", rmp2amp_r(tmp2, tmp2));
- else
+ if (playlist_saveAbsolutePaths && song_is_file(song)) {
+ const char *path = map_song_fs(song, tmp1);
+ if (path != NULL)
+ fprintf(file, "%s\n", path);
+ } else {
+ song_get_url(song, tmp1);
+ utf8_to_fs_charset(tmp2, tmp1);
fprintf(file, "%s\n", tmp2);
+ }
}
void
@@ -42,8 +46,10 @@ playlist_print_uri(FILE *file, const char *uri)
char tmp[MPD_PATH_MAX];
const char *s;
- s = utf8_to_fs_charset(tmp, uri);
if (playlist_saveAbsolutePaths && !isValidRemoteUtf8Url(s))
- s = rmp2amp_r(tmp, s);
+ s = map_directory_child_fs(db_get_root(), uri, tmp);
+ else
+ s = utf8_to_fs_charset(tmp, uri);
+
fprintf(file, "%s\n", s);
}