diff mbox

[FFmpeg-devel,v2] lavf/dashenc: Use avpriv_io_delete to delete files.

Message ID 20181130090345.27615-1-andrey.semashev@gmail.com
State Accepted
Commit a68a975584462e1cdd1b810956e43025efb6eb04
Headers show

Commit Message

Andrey Semashev Nov. 30, 2018, 9:03 a.m. UTC
This fixes incorrect handling of file pseudo-URIs (i.e. when the filename
starts with "file:").
---
 libavformat/dashenc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Jeyapal, Karthick Dec. 3, 2018, 5:42 a.m. UTC | #1
On 11/30/18 2:33 PM, Andrey Semashev wrote:
> This fixes incorrect handling of file pseudo-URIs (i.e. when the filename

> starts with "file:").

> ---

>  libavformat/dashenc.c | 9 +++++++--

>  1 file changed, 7 insertions(+), 2 deletions(-)

>

> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c

> index 6ce70e0076..412d7c8a21 100644

> --- a/libavformat/dashenc.c

> +++ b/libavformat/dashenc.c

> @@ -1326,8 +1326,13 @@ static void dashenc_delete_file(AVFormatContext *s, char *filename) {

>  

>          av_dict_free(&http_opts);

>          ff_format_io_close(s, &out);

> -    } else if (unlink(filename) < 0) {

> -        av_log(s, AV_LOG_ERROR, "failed to delete %s: %s\n", filename, strerror(errno));

> +    } else {

> +        int res = avpriv_io_delete(filename);

> +        if (res < 0) {

> +            char errbuf[AV_ERROR_MAX_STRING_SIZE];

> +            av_strerror(res, errbuf, sizeof(errbuf));

> +            av_log(s, (res == AVERROR(ENOENT) ? AV_LOG_WARNING : AV_LOG_ERROR), "failed to delete %s: %s\n", filename, errbuf);

> +        }

>      }

>  }

>  

Pushed.

Regards,
Karthick
diff mbox

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6ce70e0076..412d7c8a21 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1326,8 +1326,13 @@  static void dashenc_delete_file(AVFormatContext *s, char *filename) {
 
         av_dict_free(&http_opts);
         ff_format_io_close(s, &out);
-    } else if (unlink(filename) < 0) {
-        av_log(s, AV_LOG_ERROR, "failed to delete %s: %s\n", filename, strerror(errno));
+    } else {
+        int res = avpriv_io_delete(filename);
+        if (res < 0) {
+            char errbuf[AV_ERROR_MAX_STRING_SIZE];
+            av_strerror(res, errbuf, sizeof(errbuf));
+            av_log(s, (res == AVERROR(ENOENT) ? AV_LOG_WARNING : AV_LOG_ERROR), "failed to delete %s: %s\n", filename, errbuf);
+        }
     }
 }