Bugfix, tracks were not found if STK was started in (e.g.) src.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1601 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
ef4dd43104
commit
864b6abd4e
@ -119,12 +119,13 @@ Loader::~Loader()
|
||||
void Loader::makePath(std::string& path, const std::string& dir, const std::string& fname) const
|
||||
{
|
||||
struct stat mystat;
|
||||
|
||||
|
||||
for(std::vector<std::string>::const_iterator i = m_search_path.begin();
|
||||
i != m_search_path.end(); ++i)
|
||||
{
|
||||
if(dir !="") path+=(*i)+DIR_SEPARATOR+dir;
|
||||
if(fname!="") path+=(*i)+DIR_SEPARATOR+fname;
|
||||
path=*i;
|
||||
if(dir !="") path+=DIR_SEPARATOR+dir;
|
||||
if(fname!="") path+=DIR_SEPARATOR+fname;
|
||||
if(stat(path.c_str(), &mystat) >= 0) return;
|
||||
}
|
||||
|
||||
@ -284,9 +285,9 @@ std::string Loader::getPath(const char* FNAME) const
|
||||
} // getPath
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Loader::listFiles(std::set<std::string>& result, const std::string& dir)
|
||||
const
|
||||
{
|
||||
void Loader::listFiles(std::set<std::string>& result, const std::string& dir,
|
||||
bool is_full_path) const
|
||||
{
|
||||
struct stat mystat;
|
||||
|
||||
// don't list directories with a slash on the end, it'll fail on win32
|
||||
@ -297,7 +298,7 @@ void Loader::listFiles(std::set<std::string>& result, const std::string& dir)
|
||||
for(std::vector<std::string>::const_iterator i = m_search_path.begin();
|
||||
i != m_search_path.end(); ++i)
|
||||
{
|
||||
std::string path = *i+DIR_SEPARATOR+dir;
|
||||
std::string path = is_full_path ? dir : *i+DIR_SEPARATOR+dir;
|
||||
|
||||
if(stat(path.c_str(), &mystat) < 0)
|
||||
continue;
|
||||
|
@ -55,7 +55,8 @@ public:
|
||||
|
||||
std::string getPath(const char* name) const;
|
||||
std::string getPath(const std::string name) const {return getPath(name.c_str());}
|
||||
void listFiles(std::set<std::string>& result, const std::string& dir)
|
||||
void listFiles(std::set<std::string>& result, const std::string& dir,
|
||||
bool is_full_path=false)
|
||||
const;
|
||||
|
||||
void addSearchPath(const std::string& path);
|
||||
|
@ -203,7 +203,7 @@ int handleCmdLine(int argc, char **argv)
|
||||
fprintf ( stdout, _(" Available tracks:\n") );
|
||||
for (size_t i = 0; i != track_manager->getTrackCount(); i++)
|
||||
fprintf ( stdout, "\t%10s: %s\n",
|
||||
track_manager->getTrack(i)->getIdent(),
|
||||
track_manager->getTrack(i)->getIdent().c_str(),
|
||||
track_manager->getTrack(i)->getName());
|
||||
|
||||
fprintf ( stdout, _("Use --track N to choose track.\n\n"));
|
||||
|
@ -72,11 +72,10 @@ TrackManager::loadTrackList ()
|
||||
{
|
||||
// Load up a list of tracks - and their names
|
||||
std::set<std::string> files;
|
||||
loader->listFiles(files, loader->getTrackDir());
|
||||
loader->listFiles(files, loader->getTrackDir(), /*is_full_path*/ true);
|
||||
for(std::set<std::string>::iterator i = files.begin(); i != files.end(); ++i)
|
||||
{
|
||||
if(*i=="." || *i=="..") continue;
|
||||
|
||||
std::string config_file;
|
||||
try
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user