1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

examples/avio_dir_cmd: drop support for move/delete operations

They use non-public functions, which is unacceptable for a public API
example. Rename the example back to avio_list_dir.

This effectively reverts c84d208c27 and
767d780ec0.
This commit is contained in:
Anton Khirnov 2020-01-10 12:10:09 +01:00
parent 7f0a7e3e63
commit 15546f772c
5 changed files with 9 additions and 57 deletions

4
configure vendored
View File

@ -1667,7 +1667,7 @@ COMPONENT_LIST="
" "
EXAMPLE_LIST=" EXAMPLE_LIST="
avio_dir_cmd_example avio_list_dir_example
avio_reading_example avio_reading_example
decode_audio_example decode_audio_example
decode_video_example decode_video_example
@ -3615,7 +3615,7 @@ yadif_cuda_filter_deps="ffnvcodec"
yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm" yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
# examples # examples
avio_dir_cmd_deps="avformat avutil" avio_list_dir_deps="avformat avutil"
avio_reading_deps="avformat avcodec avutil" avio_reading_deps="avformat avcodec avutil"
decode_audio_example_deps="avcodec avutil" decode_audio_example_deps="avcodec avutil"
decode_video_example_deps="avcodec avutil" decode_video_example_deps="avcodec avutil"

View File

@ -1,4 +1,4 @@
/avio_dir_cmd /avio_list_dir
/avio_reading /avio_reading
/decode_audio /decode_audio
/decode_video /decode_video

View File

@ -1,4 +1,4 @@
EXAMPLES-$(CONFIG_AVIO_DIR_CMD_EXAMPLE) += avio_dir_cmd EXAMPLES-$(CONFIG_AVIO_LIST_DIR_EXAMPLE) += avio_list_dir
EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading
EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio
EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video

View File

@ -11,7 +11,7 @@ CFLAGS += -Wall -g
CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS) CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS) LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
EXAMPLES= avio_dir_cmd \ EXAMPLES= avio_list_dir \
avio_reading \ avio_reading \
decode_audio \ decode_audio \
decode_video \ decode_video \

View File

@ -102,38 +102,15 @@ static int list_op(const char *input_dir)
return ret; return ret;
} }
static int del_op(const char *url)
{
int ret = avpriv_io_delete(url);
if (ret < 0)
av_log(NULL, AV_LOG_ERROR, "Cannot delete '%s': %s.\n", url, av_err2str(ret));
return ret;
}
static int move_op(const char *src, const char *dst)
{
int ret = avpriv_io_move(src, dst);
if (ret < 0)
av_log(NULL, AV_LOG_ERROR, "Cannot move '%s' into '%s': %s.\n", src, dst, av_err2str(ret));
return ret;
}
static void usage(const char *program_name) static void usage(const char *program_name)
{ {
fprintf(stderr, "usage: %s OPERATION entry1 [entry2]\n" fprintf(stderr, "usage: %s input_dir\n"
"API example program to show how to manipulate resources " "API example program to show how to list files in directory "
"accessed through AVIOContext.\n" "accessed through AVIOContext.\n", program_name);
"OPERATIONS:\n"
"list list content of the directory\n"
"move rename content in directory\n"
"del delete content in directory\n",
program_name);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const char *op = NULL;
int ret; int ret;
av_log_set_level(AV_LOG_DEBUG); av_log_set_level(AV_LOG_DEBUG);
@ -145,32 +122,7 @@ int main(int argc, char *argv[])
avformat_network_init(); avformat_network_init();
op = argv[1]; ret = list_op(argv[1]);
if (strcmp(op, "list") == 0) {
if (argc < 3) {
av_log(NULL, AV_LOG_INFO, "Missing argument for list operation.\n");
ret = AVERROR(EINVAL);
} else {
ret = list_op(argv[2]);
}
} else if (strcmp(op, "del") == 0) {
if (argc < 3) {
av_log(NULL, AV_LOG_INFO, "Missing argument for del operation.\n");
ret = AVERROR(EINVAL);
} else {
ret = del_op(argv[2]);
}
} else if (strcmp(op, "move") == 0) {
if (argc < 4) {
av_log(NULL, AV_LOG_INFO, "Missing argument for move operation.\n");
ret = AVERROR(EINVAL);
} else {
ret = move_op(argv[2], argv[3]);
}
} else {
av_log(NULL, AV_LOG_INFO, "Invalid operation %s\n", op);
ret = AVERROR(EINVAL);
}
avformat_network_deinit(); avformat_network_deinit();