Commit 92d366f6 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat: Print error message on failure of ff_rename()

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent eeb9242b
......@@ -204,7 +204,7 @@ static int write_manifest(AVFormatContext *s, int final)
avio_printf(out, "</manifest>\n");
avio_flush(out);
avio_close(out);
return ff_rename(temp_filename, filename);
return ff_rename(temp_filename, filename, s);
}
static void update_size(AVIOContext *out, int64_t pos)
......@@ -285,7 +285,7 @@ static int write_abst(AVFormatContext *s, OutputStream *os, int final)
update_size(out, afrt_pos);
update_size(out, 0);
avio_close(out);
return ff_rename(temp_filename, filename);
return ff_rename(temp_filename, filename, s);
}
static int init_file(AVFormatContext *s, OutputStream *os, int64_t start_ts)
......@@ -480,7 +480,7 @@ static int hds_flush(AVFormatContext *s, OutputStream *os, int final,
snprintf(target_filename, sizeof(target_filename),
"%s/stream%dSeg1-Frag%d", s->filename, index, os->fragment_index);
ret = ff_rename(os->temp_filename, target_filename);
ret = ff_rename(os->temp_filename, target_filename, s);
if (ret < 0)
return ret;
add_fragment(os, target_filename, os->frag_start_ts, end_ts - os->frag_start_ts);
......
......@@ -378,11 +378,15 @@ int ff_generate_avci_extradata(AVStream *st);
* @param newpath destination path
* @return 0 or AVERROR on failure
*/
static inline int ff_rename(const char *oldpath, const char *newpath)
static inline int ff_rename(const char *oldpath, const char *newpath, void *logctx)
{
if (rename(oldpath, newpath) == -1)
return AVERROR(errno);
return 0;
int ret = 0;
if (rename(oldpath, newpath) == -1) {
ret = AVERROR(errno);
if (logctx)
av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s\n", oldpath, newpath);
}
return ret;
}
/**
......
......@@ -283,7 +283,7 @@ static int write_manifest(AVFormatContext *s, int final)
avio_printf(out, "</SmoothStreamingMedia>\n");
avio_flush(out);
avio_close(out);
return ff_rename(temp_filename, filename);
return ff_rename(temp_filename, filename, s);
}
static int ism_write_header(AVFormatContext *s)
......@@ -540,7 +540,7 @@ static int ism_flush(AVFormatContext *s, int final)
snprintf(header_filename, sizeof(header_filename), "%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
snprintf(target_filename, sizeof(target_filename), "%s/Fragments(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
copy_moof(s, filename, header_filename, moof_size);
ret = ff_rename(filename, target_filename);
ret = ff_rename(filename, target_filename, s);
if (ret < 0)
break;
add_fragment(os, target_filename, header_filename, start_ts, duration,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment