diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2014-10-20 00:48:49 +0200 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2014-10-24 23:42:53 +0100 |
commit | 7785ce1c769369abf85b276148548a5510aabb5f (patch) | |
tree | 4df0594c42bb4f1524f509b144fd8e857e0c7dbc /libavformat/internal.h | |
parent | 0b66fb4505e0bb43de3797f63f3290f0188d67cc (diff) | |
download | ffmpeg-7785ce1c769369abf85b276148548a5510aabb5f.tar.gz |
lavf: replace rename() with ff_rename()
The new function wraps errno so that its value is correctly reported
when other functions overwrite it (eg. in case of logging).
CC: libav-stable@libav.org
Bug-Id: CID 1135748
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavformat/internal.h')
-rw-r--r-- | libavformat/internal.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavformat/internal.h b/libavformat/internal.h index c66a0458ef..d579db5a47 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -351,4 +351,18 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags); */ int ff_generate_avci_extradata(AVStream *st); +/** + * Wrap errno on rename() error. + * + * @param oldpath source path + * @param newpath destination path + * @return 0 or AVERROR on failure + */ +static inline int ff_rename(const char *oldpath, const char *newpath) +{ + if (rename(oldpath, newpath) == -1) + return AVERROR(errno); + return 0; +} + #endif /* AVFORMAT_INTERNAL_H */ |