Skip to content
Snippets Groups Projects
Commit 803e8227 authored by Martin Storsjö's avatar Martin Storsjö
Browse files

libavformat: Check mkdir return error codes


Previously, the returned error codes were intentionally ignored
(see fadd3a68), 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: default avatarMartin Storsjö <martin@martin.st>
parent 041caf1a
No related branches found
No related tags found
No related merge requests found
...@@ -323,7 +323,10 @@ static int hds_write_header(AVFormatContext *s) ...@@ -323,7 +323,10 @@ static int hds_write_header(AVFormatContext *s)
int ret = 0, i; int ret = 0, i;
AVOutputFormat *oformat; 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); oformat = av_guess_format("flv", NULL, NULL);
if (!oformat) { if (!oformat) {
......
...@@ -292,7 +292,10 @@ static int ism_write_header(AVFormatContext *s) ...@@ -292,7 +292,10 @@ static int ism_write_header(AVFormatContext *s)
int ret = 0, i; int ret = 0, i;
AVOutputFormat *oformat; 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); oformat = av_guess_format("ismv", NULL, NULL);
if (!oformat) { if (!oformat) {
...@@ -319,7 +322,10 @@ static int ism_write_header(AVFormatContext *s) ...@@ -319,7 +322,10 @@ static int ism_write_header(AVFormatContext *s)
goto fail; goto fail;
} }
snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codec->bit_rate); 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(); ctx = avformat_alloc_context();
if (!ctx) { if (!ctx) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment