aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory_save.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-01-24 19:07:11 +0100
committerMax Kellermann <max@duempel.org>2012-01-24 20:03:18 +0100
commit420a4c163d4147b6354244cba69fbdd78e17ced2 (patch)
tree2e247c381ffd087a6a7a981e432f827b147dcac7 /src/directory_save.c
parent1bab735580f83932407b90c722bd021a49c389e8 (diff)
downloadmpd-420a4c163d4147b6354244cba69fbdd78e17ced2.tar.gz
mpd-420a4c163d4147b6354244cba69fbdd78e17ced2.tar.xz
mpd-420a4c163d4147b6354244cba69fbdd78e17ced2.zip
directory: simplify constructors and clarify API documentation
Pass only the "name" to a directory, instead of the full (relative) path.
Diffstat (limited to 'src/directory_save.c')
-rw-r--r--src/directory_save.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/directory_save.c b/src/directory_save.c
index 912e71e0e..975e2e745 100644
--- a/src/directory_save.c
+++ b/src/directory_save.c
@@ -81,7 +81,6 @@ static struct directory *
directory_load_subdir(FILE *fp, struct directory *parent, const char *name,
GString *buffer, GError **error_r)
{
- struct directory *directory;
const char *line;
bool success;
@@ -91,20 +90,13 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name,
return NULL;
}
- if (directory_is_root(parent)) {
- directory = directory_new(name, parent);
- } else {
- char *path = g_strconcat(directory_get_path(parent), "/",
- name, NULL);
- directory = directory_new(path, parent);
- g_free(path);
- }
+ struct directory *directory = directory_new_child(parent, name);
line = read_text_line(fp, buffer);
if (line == NULL) {
g_set_error(error_r, directory_quark(), 0,
"Unexpected end of file");
- directory_free(directory);
+ directory_delete(directory);
return NULL;
}
@@ -117,7 +109,7 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name,
if (line == NULL) {
g_set_error(error_r, directory_quark(), 0,
"Unexpected end of file");
- directory_free(directory);
+ directory_delete(directory);
return NULL;
}
}
@@ -125,13 +117,13 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name,
if (!g_str_has_prefix(line, DIRECTORY_BEGIN)) {
g_set_error(error_r, directory_quark(), 0,
"Malformed line: %s", line);
- directory_free(directory);
+ directory_delete(directory);
return NULL;
}
success = directory_load(fp, directory, buffer, error_r);
if (!success) {
- directory_free(directory);
+ directory_delete(directory);
return NULL;
}
@@ -153,8 +145,6 @@ directory_load(FILE *fp, struct directory *directory,
buffer, error);
if (subdir == NULL)
return false;
-
- dirvec_add(&directory->children, subdir);
} else if (g_str_has_prefix(line, SONG_BEGIN)) {
const char *name = line + sizeof(SONG_BEGIN) - 1;
struct song *song;