From f2a5461bccc641c99ef6d8569a1e0484e279c1e3 Mon Sep 17 00:00:00 2001 From: yo mama Date: Sat, 31 Jan 2015 00:19:49 -0800 Subject: added file checking --- src/LV2-render.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/LV2-render.c') diff --git a/src/LV2-render.c b/src/LV2-render.c index 490f1ae..124c6dd 100644 --- a/src/LV2-render.c +++ b/src/LV2-render.c @@ -79,6 +79,9 @@ #include "midi/fluidsynth_priv.h" #define DEBUG 0 +#define FILE_OK 0x0 +#define WRITE_OK 0x2 + int min(int x, int y) { return (x < y) ? x : y; @@ -592,6 +595,19 @@ main(int argc, char** argv) strcpy(jalv.opts.infile, "test.mid"); } + + //make sure input and output exist + if(access(jalv.opts.infile, FILE_OK)){ + fprintf(stderr, "ERROR:Could not find %s\n Please specify an input file with -i\n", jalv.opts.infile); + exit(1); + } + if(!access(jalv.opts.outfile, WRITE_OK)){ + fprintf(stderr, "ERROR:Could not write to %s\n.", jalv.opts.outfile); + exit(1); + } + + + if (! jalv.opts.sample_rate){ jalv.opts.sample_rate = 48000; } -- cgit v1.2.3-70-g09d2