aboutsummaryrefslogtreecommitdiff
path: root/src/stored_playlist.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-18 16:15:45 +0100
committerMax Kellermann <max@duempel.org>2009-01-18 16:15:45 +0100
commit9933144de7389b12b2a75cfb4320baecefa952af (patch)
tree09d7fc155aa64e596c38a2a7d7908e6c8705bf3b /src/stored_playlist.c
parentc2cc3b4923684cb00518e7b8db25a9b56c60dc9d (diff)
mapper: make the playlist directory optional
Diffstat (limited to 'src/stored_playlist.c')
-rw-r--r--src/stored_playlist.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/stored_playlist.c b/src/stored_playlist.c
index e6fdf944..94170283 100644
--- a/src/stored_playlist.c
+++ b/src/stored_playlist.c
@@ -80,6 +80,9 @@ spl_list(void)
GPtrArray *list;
struct stored_playlist_info *playlist;
+ if (parent_path_fs == NULL)
+ return NULL;
+
dir = opendir(parent_path_fs);
if (dir == NULL)
return NULL;
@@ -118,6 +121,8 @@ spl_save(GPtrArray *list, const char *utf8path)
assert(utf8path != NULL);
path_fs = map_spl_utf8_to_fs(utf8path);
+ if (path_fs == NULL)
+ return PLAYLIST_RESULT_DISABLED;
while (!(file = fopen(path_fs, "w")) && errno == EINTR);
g_free(path_fs);
@@ -145,6 +150,8 @@ spl_load(const char *utf8path)
return NULL;
path_fs = map_spl_utf8_to_fs(utf8path);
+ if (path_fs == NULL)
+ return NULL;
while (!(file = fopen(path_fs, "r")) && errno == EINTR);
g_free(path_fs);
@@ -264,6 +271,8 @@ spl_clear(const char *utf8path)
return PLAYLIST_RESULT_BAD_NAME;
path_fs = map_spl_utf8_to_fs(utf8path);
+ if (path_fs == NULL)
+ return PLAYLIST_RESULT_DISABLED;
while (!(file = fopen(path_fs, "w")) && errno == EINTR);
g_free(path_fs);
@@ -283,6 +292,9 @@ spl_delete(const char *name_utf8)
int ret;
path_fs = map_spl_utf8_to_fs(name_utf8);
+ if (path_fs == NULL)
+ return PLAYLIST_RESULT_DISABLED;
+
ret = unlink(path_fs);
g_free(path_fs);
if (ret < 0)
@@ -330,6 +342,8 @@ spl_append_song(const char *utf8path, struct song *song)
return PLAYLIST_RESULT_BAD_NAME;
path_fs = map_spl_utf8_to_fs(utf8path);
+ if (path_fs == NULL)
+ return PLAYLIST_RESULT_DISABLED;
while (!(file = fopen(path_fs, "a")) && errno == EINTR);
g_free(path_fs);
@@ -410,7 +424,10 @@ spl_rename(const char *utf8from, const char *utf8to)
from_path_fs = map_spl_utf8_to_fs(utf8from);
to_path_fs = map_spl_utf8_to_fs(utf8to);
- ret = spl_rename_internal(from_path_fs, to_path_fs);
+ if (from_path_fs != NULL && to_path_fs != NULL)
+ ret = spl_rename_internal(from_path_fs, to_path_fs);
+ else
+ ret = PLAYLIST_RESULT_DISABLED;
g_free(from_path_fs);
g_free(to_path_fs);