dungeon_crawler

view prototype/src/datapath.cc @ 63:7f52d6310317

fixed design issue with datafile_path
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 02 Oct 2012 04:52:59 +0300
parents 91180ee7b7d9
children
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 std::string datafile_path(const char *fname)
14 {
15 std::string res;
16 if(!fname) {
17 return res;
18 }
20 for(auto path : pathlist) {
21 res = path + "/" + std::string(fname);
22 FILE *fp = fopen(res.c_str(), "r");
23 if(fp) {
24 fclose(fp);
25 return res;
26 }
27 }
28 return std::string(fname);
29 }