[FFmpeg-cvslog] avformat/avio: fix ff_rename to respect used protocol
Marton Balint
git at videolan.org
Sun Jan 19 23:36:02 EET 2020
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sun Jan 5 16:32:51 2020 +0100| [19b9f8996e1a6a17830123b4bc22dbc735c1570e] | committer: Marton Balint
avformat/avio: fix ff_rename to respect used protocol
Also simplify it and make it always log the error.
This fixes for example the image2 muxer when used with an URL which also
contains the protocol:
ffmpeg -f lavfi -i testsrc -vframes 10 -atomic_writing 1 file:out%d.png
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=19b9f8996e1a6a17830123b4bc22dbc735c1570e
---
libavformat/avio.c | 14 ++++----------
libavformat/internal.h | 8 ++++----
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 8c2c85f171..65cfc0f4bb 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -667,16 +667,10 @@ int ff_check_interrupt(AVIOInterruptCB *cb)
return 0;
}
-int ff_rename(const char *oldpath, const char *newpath, void *logctx)
+int ff_rename(const char *url_src, const char *url_dst, void *logctx)
{
- int ret = 0;
- if (rename(oldpath, newpath) == -1) {
- ret = AVERROR(errno);
- if (logctx) {
- char err[AV_ERROR_MAX_STRING_SIZE] = {0};
- av_make_error_string(err, AV_ERROR_MAX_STRING_SIZE, ret);
- av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s: %s\n", oldpath, newpath, err);
- }
- }
+ int ret = avpriv_io_move(url_src, url_dst);
+ if (ret < 0)
+ av_log(logctx, AV_LOG_ERROR, "failed to rename file %s to %s: %s\n", url_src, url_dst, av_err2str(ret));
return ret;
}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index da09983083..332477a532 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -580,13 +580,13 @@ int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *a
int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
/**
- * Wrap errno on rename() error.
+ * Wrap avpriv_io_move and log if error happens.
*
- * @param oldpath source path
- * @param newpath destination path
+ * @param url_src source path
+ * @param url_dst destination path
* @return 0 or AVERROR on failure
*/
-int ff_rename(const char *oldpath, const char *newpath, void *logctx);
+int ff_rename(const char *url_src, const char *url_dst, void *logctx);
/**
* Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end
More information about the ffmpeg-cvslog
mailing list