X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=file.c;h=1e02c8eace6d47dad5c96f5d0e0bffd281f534d8;hp=0c6177f84d57eb65fbf35cac804beda0eeb5e2c0;hb=31a00c721be0b569bc554069cc0a3eb2864eb61f;hpb=4aca4a973f11e4636a7797af416b4c03e41740a0 diff --git a/file.c b/file.c index 0c6177f..1e02c8e 100644 --- a/file.c +++ b/file.c @@ -31,12 +31,11 @@ char *g_data_dir; char *g_score_file; -mode_t g_score_mask; -char * +static char * add_path(char *path, char *file) { - char *s; + char *r, *s; size_t plen, flen; if(!path || !file) return NULL; @@ -58,27 +57,23 @@ add_data_path(char *filename) #ifdef WIN32 -bool -is_dir(char *dirname) +static bool +find_data_dir(void) { - WIN32_FILE_ATTRIBUTE_DATA buf; - if(!GetFileAttributesEx(dirname, GetFileExInfoStandard, &buf)) - return false; - return buf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; + g_data_dir = "."; + return true; } -bool -is_file(char *filename) +static bool +find_score_file(void) { - WIN32_FILE_ATTRIBUTE_DATA buf; - if(!GetFileAttributesEx(filename, GetFileExInfoStandard, &buf)) - return false; - return buf.dwFileAttributes & FILE_ATTRIBUTE_NORMAL; + g_score_file = "scores"; + return true; } #else /* !WIN32 */ -bool +static bool is_dir(char *dirname) { struct stat buf; @@ -86,17 +81,7 @@ is_dir(char *dirname) return S_ISDIR(buf.st_mode); } -bool -is_file(char *filename) -{ - struct stat buf; - stat(filename, &buf); - return S_ISREG(buf.st_mode); -} - -#endif /* !WIN32 */ - -bool +static bool find_data_dir(void) { int i; @@ -119,7 +104,7 @@ find_data_dir(void) return false; } -bool +static bool find_score_file(void) { char *dir, *s; @@ -131,11 +116,12 @@ find_score_file(void) s = add_path(dir, ".vor-scores"); if(s) { g_score_file = s; - g_score_mask = 0177; return true; } else return false; } +#endif /* !WIN32 */ + bool find_files(void) { @@ -145,13 +131,6 @@ find_files(void) FILE * open_score_file(char *mode) { - mode_t old_mask; - FILE *f; - if(!g_score_file) return NULL; - - old_mask = umask(g_score_mask); - f = fopen(g_score_file, mode); - umask(old_mask); - return f; + return fopen(g_score_file, mode); }