1 /* Variations on RockDodger
2 * Copyright (C) 2004 Joshua Grams <josh@qualdan.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sys/types.h>
34 add_path(char *filename)
36 static char r[MAX_PATH_LEN];
37 snprintf(r, MAX_PATH_LEN, "%s/%s", g_data_dir, filename);
46 return S_ISDIR(buf.st_mode);
50 is_file(char *filename)
54 return S_ISREG(buf.st_mode);
61 char *data_options[3] = {
68 if(!data_options[i]) continue;
69 g_data_dir = strdup(data_options[i]);
70 if(is_dir(g_data_dir)) return true;
73 fprintf(stderr, "Can't find VoR data! Tried:\n");
75 fprintf(stderr, "\t%s\n", data_options[i]);
83 g_score_file = add_path("scores");
85 if(is_file(g_score_file)) {
86 g_score_file = strdup(g_score_file);
90 g_score_file = malloc(MAX_PATH_LEN);
91 snprintf(g_score_file, MAX_PATH_LEN,
92 "%s/.vor-high", getenv("HOME"));
94 if(is_file(g_score_file)) return true;
109 open_score_file(char *mode)
114 if(!g_score_file) return f;
116 old_mask = umask(g_score_mode);
117 f = fopen(g_score_file, mode);