+static int hls_delete_file(HLSContext *hls, AVFormatContext *avf,
+ const char *path, const char *proto)
+{
+ if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
+ AVDictionary *opt = NULL;
+ AVIOContext *out = NULL;
+ int ret;
+ av_dict_set(&opt, "method", "DELETE", 0);
+ ret = avf->io_open(avf, &out, path, AVIO_FLAG_WRITE, &opt);
+ av_dict_free(&opt);
+ if (ret < 0)
+ return hls->ignore_io_errors ? 1 : ret;
+ ff_format_io_close(avf, &out);
+ } else if (unlink(path) < 0) {
+ av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
+ path, strerror(errno));
+ }
+ return 0;
+}
+