int ret = 0, path_size, sub_path_size;
char *dirname = NULL, *p, *sub_path;
char *path = NULL;
+ AVDictionary *options = NULL;
+ AVIOContext *out = NULL;
segment = hls->segments;
while (segment) {
av_strlcat(path, segment->filename, path_size);
}
- if (unlink(path) < 0) {
+ if (hls->method) {
+ av_dict_set(&options, "method", "DELETE", 0);
+ if ((ret = hls->avf->io_open(hls->avf, &out, path, AVIO_FLAG_WRITE, &options)) < 0)
+ goto fail;
+ } else if (unlink(path) < 0) {
av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
}
av_strlcpy(sub_path, dirname, sub_path_size);
av_strlcat(sub_path, segment->sub_filename, sub_path_size);
- if (unlink(sub_path) < 0) {
+
+ if (hls->method) {
+ av_dict_set(&options, "method", "DELETE", 0);
+ if ((ret = hls->avf->io_open(hls->avf, &out, sub_path, AVIO_FLAG_WRITE, &options)) < 0) {
+ av_free(sub_path);
+ goto fail;
+ }
+ } else if (unlink(sub_path) < 0) {
av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
sub_path, strerror(errno));
}