X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=file.c;h=efd08e5a0f23ac78f9444312349de8779c8ce4d8;hp=3a02b81f38fbd0c958416ece2d7a0ba09a3a5d92;hb=HEAD;hpb=474fd4f894f57b7d53a22e15b31b8749c42e9a53 diff --git a/file.c b/file.c index 3a02b81..5f6204d 100644 --- a/file.c +++ b/file.c @@ -26,7 +26,7 @@ #include #include "common.h" -#include "config.h" +#include "vorconfig.h" #include "file.h" #ifdef WIN32 @@ -52,7 +52,8 @@ find_files(void) return true; } -FILE *open_score_file(char *mode) +FILE * +open_score_file(char *mode) { return fopen("scores", mode); } @@ -91,11 +92,23 @@ static bool is_dir(char *dirname) { struct stat buf; - stat(dirname, &buf); + if(stat(dirname, &buf)) { + return false; + } return S_ISDIR(buf.st_mode); } static bool +is_file(char *filename) +{ + struct stat buf; + if(stat(filename, &buf)) { + return false; + } + return S_ISREG(buf.st_mode); +} + +static bool find_data_dir(void) { int i; @@ -108,12 +121,16 @@ find_data_dir(void) for(i=0; i<3; i++) { if(!data_options[i]) continue; g_data_dir = strdup(data_options[i]); - if(is_dir(g_data_dir)) return true; + if(is_dir(g_data_dir)) { + char *s = add_path(g_data_dir, "b_variations.png"); + if(s) if(is_file(s)) + return true; + } } fprintf(stderr, "Can't find VoR data! Tried:\n"); for(i=0; i<3; i++) { - fprintf(stderr, "\t%s\n", data_options[i]); + if(data_options[i]) fprintf(stderr, "\t%s\n", data_options[i]); } return false; }