dungeon_crawler
annotate prototype/src/datapath.cc @ 16:91180ee7b7d9
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 20 Aug 2012 03:40:51 +0300 |
parents | 252a00508411 |
children | 7f52d6310317 |
rev | line source |
---|---|
nuclear@5 | 1 #include <stdio.h> |
nuclear@5 | 2 #include <vector> |
nuclear@5 | 3 #include <string> |
nuclear@5 | 4 #include "datapath.h" |
nuclear@5 | 5 |
nuclear@5 | 6 static std::vector<std::string> pathlist; |
nuclear@5 | 7 |
nuclear@5 | 8 void add_data_path(const char *path) |
nuclear@5 | 9 { |
nuclear@5 | 10 pathlist.push_back(path); |
nuclear@5 | 11 } |
nuclear@5 | 12 |
nuclear@5 | 13 const char *datafile_path(const char *fname) |
nuclear@5 | 14 { |
nuclear@5 | 15 static std::string res; |
nuclear@5 | 16 |
nuclear@16 | 17 if(!fname) { |
nuclear@16 | 18 return 0; |
nuclear@16 | 19 } |
nuclear@16 | 20 |
nuclear@5 | 21 for(auto path : pathlist) { |
nuclear@5 | 22 res = path + "/" + std::string(fname); |
nuclear@5 | 23 FILE *fp = fopen(res.c_str(), "r"); |
nuclear@5 | 24 if(fp) { |
nuclear@5 | 25 fclose(fp); |
nuclear@5 | 26 return res.c_str(); |
nuclear@5 | 27 } |
nuclear@5 | 28 } |
nuclear@5 | 29 return 0; |
nuclear@5 | 30 } |