summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/database.c4
-rw-r--r--src/directory_save.c29
-rw-r--r--src/directory_save.h2
3 files changed, 16 insertions, 19 deletions
diff --git a/src/database.c b/src/database.c
index 70fce0c18..2164a69b7 100644
--- a/src/database.c
+++ b/src/database.c
@@ -251,7 +251,9 @@ db_save(void)
fprintf(fp, "%s\n", DIRECTORY_INFO_END);
- if (directory_save(fp, music_root) < 0) {
+ directory_save(fp, music_root);
+
+ if (ferror(fp)) {
g_warning("Failed to write to database file: %s",
strerror(errno));
while (fclose(fp) && errno == EINTR);
diff --git a/src/directory_save.c b/src/directory_save.c
index a22d28ffb..317f64bb4 100644
--- a/src/directory_save.c
+++ b/src/directory_save.c
@@ -39,43 +39,38 @@ directory_quark(void)
return g_quark_from_static_string("directory");
}
-/* TODO error checking */
-int
+void
directory_save(FILE *fp, struct directory *directory)
{
struct dirvec *children = &directory->children;
size_t i;
- int retv;
if (!directory_is_root(directory)) {
fprintf(fp, DIRECTORY_MTIME "%lu\n",
(unsigned long)directory->mtime);
- retv = fprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
- directory_get_path(directory));
- if (retv < 0)
- return -1;
+ fprintf(fp, "%s%s\n", DIRECTORY_BEGIN,
+ directory_get_path(directory));
}
for (i = 0; i < children->nr; ++i) {
struct directory *cur = children->base[i];
char *base = g_path_get_basename(cur->path);
- retv = fprintf(fp, DIRECTORY_DIR "%s\n", base);
+ fprintf(fp, DIRECTORY_DIR "%s\n", base);
g_free(base);
- if (retv < 0)
- return -1;
- if (directory_save(fp, cur) < 0)
- return -1;
+
+ directory_save(fp, cur);
+
+ if (ferror(fp))
+ return;
}
songvec_save(fp, &directory->songs);
- if (!directory_is_root(directory) &&
- fprintf(fp, DIRECTORY_END "%s\n",
- directory_get_path(directory)) < 0)
- return -1;
- return 0;
+ if (!directory_is_root(directory))
+ fprintf(fp, DIRECTORY_END "%s\n",
+ directory_get_path(directory));
}
static struct directory *
diff --git a/src/directory_save.h b/src/directory_save.h
index d9daa3fed..fa2775624 100644
--- a/src/directory_save.h
+++ b/src/directory_save.h
@@ -27,7 +27,7 @@
struct directory;
-int
+void
directory_save(FILE *fp, struct directory *directory);
bool