From 474fd4f894f57b7d53a22e15b31b8749c42e9a53 Mon Sep 17 00:00:00 2001 From: Joshua Grams Date: Mon, 10 Apr 2006 01:07:58 +0000 Subject: [PATCH] windows port, maybe? --- common.h | 4 ---- file.c | 58 ++++++++++++++++++++++++++++++++++++---------------------- file.h | 6 ------ 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/common.h b/common.h index 28d9ea0..b0f32ff 100644 --- a/common.h +++ b/common.h @@ -21,8 +21,4 @@ #define CONDERROR(a) if((a)) {initerror = strdup(SDL_GetError());return 1;} #define NULLERROR(a) CONDERROR((a) == NULL) -#ifdef WIN32 -# include -#endif - #endif // VOR_COMMON_H diff --git a/file.c b/file.c index 1e02c8e..3a02b81 100644 --- a/file.c +++ b/file.c @@ -29,13 +29,45 @@ #include "config.h" #include "file.h" +#ifdef WIN32 + +#define DATA_DIR "data\\" + +char * +add_data_path(char *filename) +{ + char *s; + if(!filename) return filename; + s = malloc(sizeof(DATA_DIR)+strlen(filename)); + if(s) { + strcpy(s, DATA_DIR); + strcpy(s+sizeof(DATA_DIR)-1, filename); + } + return s; +} + +bool +find_files(void) +{ + return true; +} + +FILE *open_score_file(char *mode) +{ + return fopen("scores", mode); +} + + +#else /* !WIN32 */ + + char *g_data_dir; char *g_score_file; static char * add_path(char *path, char *file) { - char *r, *s; + char *s; size_t plen, flen; if(!path || !file) return NULL; @@ -44,7 +76,7 @@ add_path(char *path, char *file) s = malloc(2+plen+flen); if(!s) return NULL; memcpy(s, path, plen); - s[plen] = PATH_SEPARATOR; + s[plen] = '/'; memcpy(s+plen+1, file, flen+1); return s; } @@ -55,24 +87,6 @@ add_data_path(char *filename) return add_path(g_data_dir, filename); } -#ifdef WIN32 - -static bool -find_data_dir(void) -{ - g_data_dir = "."; - return true; -} - -static bool -find_score_file(void) -{ - g_score_file = "scores"; - return true; -} - -#else /* !WIN32 */ - static bool is_dir(char *dirname) { @@ -120,8 +134,6 @@ find_score_file(void) } else return false; } -#endif /* !WIN32 */ - bool find_files(void) { @@ -134,3 +146,5 @@ open_score_file(char *mode) if(!g_score_file) return NULL; return fopen(g_score_file, mode); } + +#endif /* !WIN32 */ diff --git a/file.h b/file.h index df76403..51045cc 100644 --- a/file.h +++ b/file.h @@ -26,10 +26,4 @@ char *add_data_path(char *filename); bool find_files(void); FILE *open_score_file(char *mode); -#ifdef WIN32 -# define PATH_SEPARATOR '\\' -#else -# define PATH_SEPARATOR '/' -#endif - #endif // VOR_FILE_H -- 1.7.10.4