Changeset 0a509c6


Ignore:
Timestamp:
Dec 8, 2013, 5:51:09 AM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
664fd25
Parents:
a93dab3
Message:

examples/: check if sink_uri exists, add -f to force overwrite

Location:
examples
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • examples/parse_args.h

    ra93dab3 r0a509c6  
    4141extern uint_t mix_input;
    4242
     43extern uint_t force_overwrite;
     44
    4345// functions defined in utils.c
    4446extern void examples_common_init (int argc, char **argv);
     
    7981#ifdef PROG_HAS_OUTPUT
    8082      "       -m      --mix-input        mix input signal with output signal\n"
     83      "       -f      --force-overwrite  overwrite output file if\n"
    8184#endif
    8285#ifdef PROG_HAS_JACK
     
    106109    "p:u:l:"
    107110#endif /* PROG_HAS_PITCH */
    108     "s:m";
     111    "s:mf";
    109112  int next_option;
    110113  struct option long_options[] = {
     
    132135    {"silence",               1, NULL, 's'},
    133136    {"mix-input",             0, NULL, 'm'},
     137    {"force-overwrite",       0, NULL, 'f'},
    134138    {NULL,                    0, NULL, 0}
    135139  };
     
    156160      case 'o':
    157161        sink_uri = optarg;
     162        break;
     163      case 'f':                /* force_overwrite flag */
     164        force_overwrite = 1;
    158165        break;
    159166      case 'r':
  • examples/utils.c

    ra93dab3 r0a509c6  
    5454uint_t mix_input = 0;
    5555
     56uint_t force_overwrite = 0;
     57
    5658//
    5759// internal memory stuff
     
    8991    }
    9092    if (sink_uri != NULL) {
     93      uint_t sink_exists = (access(sink_uri, F_OK) == 0 );
     94      if (!force_overwrite && sink_exists) {
     95        outmsg ("Output file %s already exists, use -f to overwrite.\n",
     96            sink_uri);
     97        exit (1);
     98      }
    9199      this_sink = new_aubio_sink ((char_t*)sink_uri, samplerate);
    92100      if (this_sink == NULL) {
Note: See TracChangeset for help on using the changeset viewer.