Fixing windows/linux paths. Metadb for hyperlists now generate.

This commit is contained in:
emb 2015-04-06 21:32:36 -05:00
parent 0ee4dc5cab
commit f394098e6e
4 changed files with 5 additions and 17 deletions

View File

@ -275,7 +275,6 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
{ {
std::string file = dirp->d_name; std::string file = dirp->d_name;
Utils::NormalizeBackSlashes(file);
size_t position = file.find_last_of("."); size_t position = file.find_last_of(".");
std::string basename = (std::string::npos == position)? file : file.substr(0, position); std::string basename = (std::string::npos == position)? file : file.substr(0, position);

View File

@ -110,7 +110,7 @@ bool MetadataDatabase::ImportDirectory()
{ {
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
std::string hyperListPath = Utils::CombinePath(Configuration::GetAbsolutePath() + "meta", "hyperlist"); std::string hyperListPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "meta", "hyperlist");
std::string mameListPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "meta", "mamelist"); std::string mameListPath = Utils::CombinePath(Configuration::GetAbsolutePath(), "meta", "mamelist");
dp = opendir(hyperListPath.c_str()); dp = opendir(hyperListPath.c_str());

View File

@ -170,11 +170,6 @@ int Utils::ConvertInt(std::string content)
return retVal; return retVal;
} }
void Utils::NormalizeBackSlashes(std::string& content)
{
std::replace(content.begin(), content.end(), '\\', '/');
}
void Utils::ReplaceSlashesWithUnderscores(std::string &content) void Utils::ReplaceSlashesWithUnderscores(std::string &content)
{ {
std::replace(content.begin(), content.end(), '\\', '_'); std::replace(content.begin(), content.end(), '\\', '_');
@ -185,10 +180,9 @@ void Utils::ReplaceSlashesWithUnderscores(std::string &content)
std::string Utils::GetDirectory(std::string filePath) std::string Utils::GetDirectory(std::string filePath)
{ {
NormalizeBackSlashes(filePath);
std::string directory = filePath; std::string directory = filePath;
const size_t last_slash_idx = filePath.rfind('/'); const size_t last_slash_idx = filePath.rfind(PathSeparator);
if (std::string::npos != last_slash_idx) if (std::string::npos != last_slash_idx)
{ {
directory = filePath.substr(0, last_slash_idx); directory = filePath.substr(0, last_slash_idx);
@ -199,14 +193,11 @@ std::string Utils::GetDirectory(std::string filePath)
std::string Utils::GetParentDirectory(std::string directory) std::string Utils::GetParentDirectory(std::string directory)
{ {
size_t last_slash_idx = directory.find_last_of(PathSeparator);
NormalizeBackSlashes(directory);
size_t last_slash_idx = directory.find_last_of('/');
if(directory.length() - 1 == last_slash_idx) if(directory.length() - 1 == last_slash_idx)
{ {
directory = directory.erase(last_slash_idx, directory.length()-1); directory = directory.erase(last_slash_idx, directory.length()-1);
last_slash_idx = directory.find_last_of('/'); last_slash_idx = directory.find_last_of(PathSeparator);
} }
if (std::string::npos != last_slash_idx) if (std::string::npos != last_slash_idx)
@ -221,10 +212,9 @@ std::string Utils::GetParentDirectory(std::string directory)
std::string Utils::GetFileName(std::string filePath) std::string Utils::GetFileName(std::string filePath)
{ {
NormalizeBackSlashes(filePath);
std::string filename = filePath; std::string filename = filePath;
const size_t last_slash_idx = filePath.rfind('/'); const size_t last_slash_idx = filePath.rfind(PathSeparator);
if (std::string::npos != last_slash_idx) if (std::string::npos != last_slash_idx)
{ {
filename = filePath.erase(0, last_slash_idx+1); filename = filePath.erase(0, last_slash_idx+1);

View File

@ -26,7 +26,6 @@ public:
static float ConvertFloat(std::string content); static float ConvertFloat(std::string content);
static int ConvertInt(std::string content); static int ConvertInt(std::string content);
static void NormalizeBackSlashes(std::string &content);
static void ReplaceSlashesWithUnderscores(std::string &content); static void ReplaceSlashesWithUnderscores(std::string &content);
static std::string GetDirectory(std::string filePath); static std::string GetDirectory(std::string filePath);
static std::string GetParentDirectory(std::string filePath); static std::string GetParentDirectory(std::string filePath);