aboutsummaryrefslogtreecommitdiffstats
path: root/src/song.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-18 04:29:53 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-18 04:29:53 -0700
commit71ac281579c8b8b384cfc09d8627b549b1854fcd (patch)
treeb501975bac64ac2cb1be1e30860302ccb3eda67e /src/song.c
parentba4f62f7d241e2837111102a4dda0c917d544c99 (diff)
downloadmpd-71ac281579c8b8b384cfc09d8627b549b1854fcd.tar.gz
mpd-71ac281579c8b8b384cfc09d8627b549b1854fcd.tar.xz
mpd-71ac281579c8b8b384cfc09d8627b549b1854fcd.zip
Move away from fprintf() when writing DB/state_file
I have serious trust issues when using stdio to write to the FS. So it's best to clean this code out so I can start figuring out what's wrong with Rasi's box not updating... None of these writes take place in a performance-critical setting anyways...
Diffstat (limited to 'src/song.c')
-rw-r--r--src/song.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/song.c b/src/song.c
index 9b8b7d4db..ab900a6b4 100644
--- a/src/song.c
+++ b/src/song.c
@@ -164,22 +164,21 @@ int printSongInfoFromList(int fd, SongList * list)
return 0;
}
-void writeSongInfoFromList(FILE * fp, SongList * list)
+void writeSongInfoFromList(int fd, SongList * list)
{
ListNode *tempNode = list->firstNode;
- fprintf(fp, "%s\n", SONG_BEGIN);
+ fdprintf(fd, SONG_BEGIN "\n");
while (tempNode != NULL) {
- fprintf(fp, "%s%s\n", SONG_KEY, tempNode->key);
- fflush(fp);
- printSongInfo(fileno(fp), (Song *) tempNode->data);
- fprintf(fp, "%s%li\n", SONG_MTIME,
+ fdprintf(fd, SONG_KEY "%s\n", tempNode->key);
+ printSongInfo(fd, (Song *) tempNode->data);
+ fdprintf(fd, SONG_MTIME "%li\n",
(long)((Song *) tempNode->data)->mtime);
tempNode = tempNode->nextNode;
}
- fprintf(fp, "%s\n", SONG_END);
+ fdprintf(fd, SONG_END "\n");
}
static void insertSongIntoList(SongList * list, ListNode ** nextSongNode,