[FFmpeg-cvslog] avformat: Print error message on failure of ff_rename()
Michael Niedermayer
git at videolan.org
Sat Oct 25 13:40:04 CEST 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Oct 25 13:04:18 2014 +0200| [92d366f6abf85ebff5f0562894c8f94ebe80f114] | committer: Michael Niedermayer
avformat: Print error message on failure of ff_rename()
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=92d366f6abf85ebff5f0562894c8f94ebe80f114
---
libavformat/hdsenc.c | 6 +++---
libavformat/internal.h | 12 ++++++++----
libavformat/smoothstreamingenc.c | 4 ++--
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index faa32c7..98106f4 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 d2aab30..f7a79dd 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 fa9984a..51a8f6f 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,
More information about the ffmpeg-cvslog
mailing list