dungeon_crawler
diff prototype/src/datapath.cc @ 5:252a00508411
more stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 12 Aug 2012 07:07:57 +0300 |
parents | |
children | 91180ee7b7d9 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/prototype/src/datapath.cc Sun Aug 12 07:07:57 2012 +0300 1.3 @@ -0,0 +1,26 @@ 1.4 +#include <stdio.h> 1.5 +#include <vector> 1.6 +#include <string> 1.7 +#include "datapath.h" 1.8 + 1.9 +static std::vector<std::string> pathlist; 1.10 + 1.11 +void add_data_path(const char *path) 1.12 +{ 1.13 + pathlist.push_back(path); 1.14 +} 1.15 + 1.16 +const char *datafile_path(const char *fname) 1.17 +{ 1.18 + static std::string res; 1.19 + 1.20 + for(auto path : pathlist) { 1.21 + res = path + "/" + std::string(fname); 1.22 + FILE *fp = fopen(res.c_str(), "r"); 1.23 + if(fp) { 1.24 + fclose(fp); 1.25 + return res.c_str(); 1.26 + } 1.27 + } 1.28 + return 0; 1.29 +}