MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / assert_file_overwrite

Function assert_file_overwrite

fftools/ffmpeg_opt.c:839–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839int assert_file_overwrite(const char *filename)
840{
841 const char *proto_name = avio_find_protocol_name(filename);
842
843 if (file_overwrite && no_file_overwrite) {
844 fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
845 return AVERROR(EINVAL);
846 }
847
848 if (!file_overwrite) {
849 if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
850 if (stdin_interaction && !no_file_overwrite) {
851 fprintf(stderr,"File '%s' already exists. Overwrite? [y/N] ", filename);
852 fflush(stderr);
853 term_exit();
854 signal(SIGINT, SIG_DFL);
855 if (!read_yesno()) {
856 av_log(NULL, AV_LOG_FATAL, "Not overwriting - exiting\n");
857 return AVERROR_EXIT;
858 }
859 term_init();
860 }
861 else {
862 av_log(NULL, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename);
863 return AVERROR_EXIT;
864 }
865 }
866 }
867
868 if (proto_name && !strcmp(proto_name, "file")) {
869 for (int i = 0; i < nb_input_files; i++) {
870 InputFile *file = input_files[i];
871 if (file->ctx->iformat->flags & AVFMT_NOFILE)
872 continue;
873 if (!strcmp(filename, file->ctx->url)) {
874 av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
875 av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
876 return AVERROR(EINVAL);
877 }
878 }
879 }
880
881 return 0;
882}
883
884/* arg format is "output-stream-index:streamid-value". */
885static int opt_streamid(void *optctx, const char *opt, const char *arg)

Callers 2

of_openFunction · 0.85
dump_attachmentFunction · 0.85

Calls 6

avio_find_protocol_nameFunction · 0.85
avio_checkFunction · 0.85
term_exitFunction · 0.85
read_yesnoFunction · 0.85
av_logFunction · 0.85
term_initFunction · 0.85

Tested by

no test coverage detected