dungeon_crawler

annotate 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
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@5 17 for(auto path : pathlist) {
nuclear@5 18 res = path + "/" + std::string(fname);
nuclear@5 19 FILE *fp = fopen(res.c_str(), "r");
nuclear@5 20 if(fp) {
nuclear@5 21 fclose(fp);
nuclear@5 22 return res.c_str();
nuclear@5 23 }
nuclear@5 24 }
nuclear@5 25 return 0;
nuclear@5 26 }