JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
bump version to 0.5.8
[vor.git] / file.c
diff --git a/file.c b/file.c
index 3a02b81..5f6204d 100644 (file)
--- a/file.c
+++ b/file.c
@@ -26,7 +26,7 @@
 #include <unistd.h>
 
 #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;
 }