2012-07-20 16:14:09 +00:00
|
|
|
#include "GameData.h"
|
2012-08-02 01:43:55 +00:00
|
|
|
#include <boost/filesystem.hpp>
|
2012-07-21 19:06:24 +00:00
|
|
|
#include <iostream>
|
2012-07-20 16:14:09 +00:00
|
|
|
|
2012-07-27 16:58:27 +00:00
|
|
|
bool GameData::isFolder() { return false; }
|
|
|
|
std::string GameData::getName() { return mName; }
|
2012-08-02 01:43:55 +00:00
|
|
|
std::string GameData::getPath() { return mPath; }
|
|
|
|
std::string GameData::getDescription() { return mDescription; }
|
|
|
|
std::string GameData::getImagePath() { return mImagePath; }
|
2012-07-27 16:58:27 +00:00
|
|
|
|
2012-07-20 16:14:09 +00:00
|
|
|
GameData::GameData(SystemData* system, std::string path, std::string name)
|
|
|
|
{
|
|
|
|
mSystem = system;
|
|
|
|
mPath = path;
|
|
|
|
mName = name;
|
2012-08-02 01:43:55 +00:00
|
|
|
|
|
|
|
mDescription = "";
|
|
|
|
mImagePath = "";
|
2012-07-20 16:14:09 +00:00
|
|
|
}
|
|
|
|
|
2012-08-02 01:43:55 +00:00
|
|
|
std::string GameData::getBashPath()
|
2012-07-21 19:06:24 +00:00
|
|
|
{
|
2012-07-21 20:57:53 +00:00
|
|
|
//a quick and dirty way to insert a backslash before most characters that would mess up a bash path
|
2012-07-21 19:06:24 +00:00
|
|
|
std::string path = mPath;
|
2012-08-02 01:43:55 +00:00
|
|
|
const char* invalidChars = " '\"\\!$^&*(){}[]?;<>";
|
2012-07-21 19:06:24 +00:00
|
|
|
for(unsigned int i = 0; i < path.length(); i++)
|
|
|
|
{
|
2012-08-02 01:43:55 +00:00
|
|
|
char c;
|
|
|
|
unsigned int charNum = 0;
|
|
|
|
do {
|
|
|
|
c = invalidChars[charNum];
|
|
|
|
if(path[i] == c)
|
|
|
|
{
|
|
|
|
path.insert(i, "\\");
|
|
|
|
i++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
charNum++;
|
|
|
|
} while(c != '\0');
|
2012-07-21 19:06:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
2012-08-02 01:43:55 +00:00
|
|
|
|
|
|
|
void GameData::set(std::string name, std::string description, std::string imagePath)
|
|
|
|
{
|
|
|
|
if(!name.empty())
|
|
|
|
mName = name;
|
|
|
|
if(!description.empty())
|
|
|
|
mDescription = description;
|
|
|
|
if(!imagePath.empty() && boost::filesystem::exists(imagePath))
|
|
|
|
mImagePath = imagePath;
|
|
|
|
}
|