dungeon_crawler

diff 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 diff
     1.1 --- a/prototype/src/datapath.cc	Tue Sep 25 06:59:11 2012 +0300
     1.2 +++ b/prototype/src/datapath.cc	Tue Oct 02 04:52:59 2012 +0300
     1.3 @@ -10,12 +10,11 @@
     1.4  	pathlist.push_back(path);
     1.5  }
     1.6  
     1.7 -const char *datafile_path(const char *fname)
     1.8 +std::string datafile_path(const char *fname)
     1.9  {
    1.10 -	static std::string res;
    1.11 -
    1.12 +	std::string res;
    1.13  	if(!fname) {
    1.14 -		return 0;
    1.15 +		return res;
    1.16  	}
    1.17  
    1.18  	for(auto path : pathlist) {
    1.19 @@ -23,8 +22,8 @@
    1.20  		FILE *fp = fopen(res.c_str(), "r");
    1.21  		if(fp) {
    1.22  			fclose(fp);
    1.23 -			return res.c_str();
    1.24 +			return res;
    1.25  		}
    1.26  	}
    1.27 -	return 0;
    1.28 +	return std::string(fname);
    1.29  }