From 15b3caf2ea61356b3bbe48b4caa8e6652f901f61 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 5 Dec 2012 18:47:04 +0000 Subject: [PATCH] screenshooter: Report an error if we fail to open the file --- src/screenshooter.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/screenshooter.c b/src/screenshooter.c index 5d41bf9..19c6675 100644 --- a/src/screenshooter.c +++ b/src/screenshooter.c @@ -413,9 +413,6 @@ weston_recorder_create(struct weston_output *output, const char *filename) recorder->output = output; memset(recorder->frame, 0, size); - recorder->fd = open(filename, - O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); - header.magic = WCAP_HEADER_MAGIC; switch (output->compositor->read_format) { @@ -427,6 +424,14 @@ weston_recorder_create(struct weston_output *output, const char *filename) break; } + recorder->fd = open(filename, + O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); + + if (recorder->fd < 0) { + weston_log("problem opening output file %s: %m\n", filename); + return; + } + header.width = output->current->width; header.height = output->current->height; recorder->total += write(recorder->fd, &header, sizeof header); -- 2.7.4