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