dlight.c: use buffer_write()
This commit is contained in:
parent
4c664f2400
commit
269ddffa78
1 changed files with 2 additions and 15 deletions
17
dlight.c
17
dlight.c
|
|
@ -21,21 +21,8 @@
|
||||||
static int write_http_file(struct http_file *file, const char *dest) {
|
static int write_http_file(struct http_file *file, const char *dest) {
|
||||||
|
|
||||||
char path[4096];
|
char path[4096];
|
||||||
int rc, fd;
|
snprintf(path, sizeof(path), "%s/%s", dest, file->filename);
|
||||||
|
return buffer_write(&file->data, path);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_items(rss_t rss, struct target *t) {
|
static void process_items(rss_t rss, struct target *t) {
|
||||||
|
|
|
||||||
Reference in a new issue