ffmpeg | branch: master | Martin Storsjö <mar...@martin.st> | Fri Sep 5 22:45:11 2014 +0300| [803e82276b3716bf6012ec69e8854dae14a4fd2b] | committer: Martin Storsjö
libavformat: Check mkdir return error codes Previously, the returned error codes were intentionally ignored (see fadd3a68213), to avoid aborting if the directory already existed. If the mkdir actually failed, this was caught when opening files within the directory fails anyway. By handling the error code here (but explicitly ignoring EEXIST), the error messages and return codes in these cases are more appropriate and less confusing. Signed-off-by: Martin Storsjö <mar...@martin.st> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=803e82276b3716bf6012ec69e8854dae14a4fd2b --- libavformat/hdsenc.c | 5 ++++- libavformat/smoothstreamingenc.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index 6217c1f..882f157 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -323,7 +323,10 @@ static int hds_write_header(AVFormatContext *s) int ret = 0, i; AVOutputFormat *oformat; - mkdir(s->filename, 0777); + if (mkdir(s->filename, 0777) == -1 && errno != EEXIST) { + ret = AVERROR(errno); + goto fail; + } oformat = av_guess_format("flv", NULL, NULL); if (!oformat) { diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 457472d..d955b343 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -292,7 +292,10 @@ static int ism_write_header(AVFormatContext *s) int ret = 0, i; AVOutputFormat *oformat; - mkdir(s->filename, 0777); + if (mkdir(s->filename, 0777) == -1 && errno != EEXIST) { + ret = AVERROR(errno); + goto fail; + } oformat = av_guess_format("ismv", NULL, NULL); if (!oformat) { @@ -319,7 +322,10 @@ static int ism_write_header(AVFormatContext *s) goto fail; } snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codec->bit_rate); - mkdir(os->dirname, 0777); + if (mkdir(os->dirname, 0777) == -1 && errno != EEXIST) { + ret = AVERROR(errno); + goto fail; + } ctx = avformat_alloc_context(); if (!ctx) { _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog