From b8297817da06acb9e5405f19c4d1e5f01446eea6 Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Sun, 18 Nov 2018 18:44:51 +0100 Subject: [PATCH] transcode: Create destination directory if necessary --- transcode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transcode.c b/transcode.c index 47a7d8a..fd8da34 100644 --- a/transcode.c +++ b/transcode.c @@ -1,5 +1,7 @@ #include <stdio.h> #include <unistd.h> +#include <sys/stat.h> +#include <libgen.h> #include <libavutil/opt.h> #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> @@ -281,7 +283,8 @@ int main(int argc, char *argv[]) else oldsrcpath = "/var/empty/nosource"; overwrite_check(outpath, oldsrcpath, jstr(jlookup(argv[4], "srchash"), "")); - + if (access(dirname(outpath), F_OK) && mkdir(dirname(outpath), 02775)) + job_failed("Could not create target directory \"%s\": %s", dirname(outpath), strerror(errno)); demux = 0; opts = 0; parse_dict(&opts, jlookup(input, "options")); -- GitLab