mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-22 22:58:52 +01:00
Fixing windows/linux paths. Metadb for hyperlists now generate.
This commit is contained in:
parent
0ee4dc5cab
commit
f394098e6e
@ -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);
|
||||||
|
|
||||||
|
|||||||
@ -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());
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user