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
23 #include <sys/types.h>
35 add_path(char *filename)
37 static char r[MAX_PATH_LEN];
38 snprintf(r, MAX_PATH_LEN, "%s/%s", g_data_dir, filename);
47 return S_ISDIR(buf.st_mode);
51 is_file(char *filename)
55 return S_ISREG(buf.st_mode);
62 char *data_options[3] = {
69 if(!data_options[i]) continue;
70 g_data_dir = strdup(data_options[i]);
71 if(is_dir(g_data_dir)) return true;
74 fprintf(stderr, "Can't find VoR data! Tried:\n");
76 fprintf(stderr, "\t%s\n", data_options[i]);
84 g_score_file = malloc(MAX_PATH_LEN);
85 snprintf(g_score_file, MAX_PATH_LEN,
86 "%s/.vor-scores", getenv("HOME"));
88 if(is_file(g_score_file)) return true;
103 open_score_file(char *mode)
108 if(!g_score_file) return f;
110 old_mask = umask(g_score_mask);
111 f = fopen(g_score_file, mode);