diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-10-25 13:04:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-25 13:28:51 +0200 |
commit | 92d366f6abf85ebff5f0562894c8f94ebe80f114 (patch) | |
tree | 0a11b8ce02d62bab32d599cc5065b34127b8998c | |
parent | eeb9242b623c76bdda0ef842cf95d3dc03ca3b60 (diff) | |
download | ffmpeg-92d366f6abf85ebff5f0562894c8f94ebe80f114.tar.gz |
avformat: Print error message on failure of ff_rename()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/hdsenc.c | 6 | ||||
-rw-r--r-- | libavformat/internal.h | 12 | ||||
-rw-r--r-- | libavformat/smoothstreamingenc.c | 4 |
3 files changed, 13 insertions, 9 deletions
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index faa32c7a96..98106f4b71 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -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); diff --git a/libavformat/internal.h b/libavformat/internal.h index d2aab30982..f7a79dd8d7 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -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; } /** diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index fa9984a50d..51a8f6f08c 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -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, |