From 269ddffa781b4a830d067238c1aca5e56777bcb4 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 11 Nov 2011 12:23:42 +0100 Subject: [PATCH] dlight.c: use buffer_write() --- dlight.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/dlight.c b/dlight.c index 73885f7..204b7f0 100644 --- a/dlight.c +++ b/dlight.c @@ -21,21 +21,8 @@ static int write_http_file(struct http_file *file, const char *dest) { char path[4096]; - int rc, fd; - - snprintf(path, sizeof(path), "%s/%s", - dest, file->filename); - - fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0664); - if (fd < 0 && errno != EEXIST) { - error("failed to write file: %s", path); - return -1; - } - - rc = write(fd, file->data.block, file->data.len); - close(fd); - - return rc; + snprintf(path, sizeof(path), "%s/%s", dest, file->filename); + return buffer_write(&file->data, path); } static void process_items(rss_t rss, struct target *t) {