mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-05-06 04:43:33 +02:00
Adding include/exclude support after porting. Lists are also alphabetical.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
#include "../Database/Configuration.h"
|
#include "../Database/Configuration.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
CollectionInfo::CollectionInfo(std::string name,
|
CollectionInfo::CollectionInfo(std::string name,
|
||||||
std::string listPath,
|
std::string listPath,
|
||||||
@@ -88,5 +89,15 @@ std::vector<Item *> *CollectionInfo::GetItems()
|
|||||||
return &Items;
|
return &Items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CollectionInfo::ItemIsLess(Item const *lhs, Item const *rhs)
|
||||||
|
{
|
||||||
|
return lhs->GetLCTitle() < rhs->GetLCTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CollectionInfo::SortItems()
|
||||||
|
{
|
||||||
|
std::sort(Items.begin(), Items.end(), ItemIsLess);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,12 @@ public:
|
|||||||
std::string GetMetadataPath() const;
|
std::string GetMetadataPath() const;
|
||||||
std::string GetExtensions() const;
|
std::string GetExtensions() const;
|
||||||
std::vector<Item *> *GetItems();
|
std::vector<Item *> *GetItems();
|
||||||
|
void SortItems();
|
||||||
void GetExtensions(std::vector<std::string> &extensions);
|
void GetExtensions(std::vector<std::string> &extensions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static bool ItemIsLess(Item const *lhs, Item const *rhs);
|
||||||
|
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::string ListPath;
|
std::string ListPath;
|
||||||
std::string Extensions;
|
std::string Extensions;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
CollectionInfoBuilder::CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb)
|
CollectionInfoBuilder::CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb)
|
||||||
: Conf(c)
|
: Conf(c)
|
||||||
@@ -78,6 +79,33 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
|
|||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list)
|
||||||
|
{
|
||||||
|
std::ifstream includeStream(file.c_str());
|
||||||
|
|
||||||
|
if (!includeStream.good()) { return false; }
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
|
||||||
|
while(std::getline(includeStream, line))
|
||||||
|
{
|
||||||
|
|
||||||
|
if(list.find(line) == list.end())
|
||||||
|
{
|
||||||
|
Item *i = new Item();
|
||||||
|
|
||||||
|
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
|
||||||
|
|
||||||
|
i->SetFullTitle(line);
|
||||||
|
|
||||||
|
list[line] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||||
{
|
{
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
@@ -90,12 +118,17 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
|||||||
std::string excludeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Exclude.txt";
|
std::string excludeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Exclude.txt";
|
||||||
std::string launcher;
|
std::string launcher;
|
||||||
|
|
||||||
|
|
||||||
|
ImportBasicList(info, includeFile, includeFilter);
|
||||||
|
ImportBasicList(info, excludeFile, excludeFilter);
|
||||||
|
|
||||||
std::vector<std::string> extensions;
|
std::vector<std::string> extensions;
|
||||||
std::vector<std::string>::iterator extensionsIt;
|
std::vector<std::string>::iterator extensionsIt;
|
||||||
|
|
||||||
info->GetExtensions(extensions);
|
info->GetExtensions(extensions);
|
||||||
|
|
||||||
(void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher);
|
(void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher);
|
||||||
|
Logger::Write(Logger::ZONE_ERROR, "CollectionInfoBuilder", "Check path " + includeFile);
|
||||||
|
|
||||||
dp = opendir(path.c_str());
|
dp = opendir(path.c_str());
|
||||||
|
|
||||||
@@ -139,6 +172,8 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
|||||||
|
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
|
|
||||||
|
info->SortItems();
|
||||||
|
|
||||||
MetaDB.InjectMetadata(info);
|
MetaDB.InjectMetadata(info);
|
||||||
|
|
||||||
while(includeFilter.size() > 0)
|
while(includeFilter.size() > 0)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MetadataDatabase &MetaDB;
|
MetadataDatabase &MetaDB;
|
||||||
|
bool ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list);
|
||||||
bool ImportDirectory(CollectionInfo *info);
|
bool ImportDirectory(CollectionInfo *info);
|
||||||
Configuration &Conf;
|
Configuration &Conf;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -150,13 +150,3 @@ void Item::SetCloneOf(const std::string& cloneOf)
|
|||||||
{
|
{
|
||||||
CloneOf = cloneOf;
|
CloneOf = cloneOf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Item::operator<(const Item &rhs)
|
|
||||||
{
|
|
||||||
return LCTitle < rhs.LCTitle;
|
|
||||||
}
|
|
||||||
bool Item::operator>(const Item &rhs)
|
|
||||||
{
|
|
||||||
return LCTitle > rhs.LCTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ public:
|
|||||||
void SetFullTitle(const std::string& fulltitle);
|
void SetFullTitle(const std::string& fulltitle);
|
||||||
const std::string& GetCloneOf() const;
|
const std::string& GetCloneOf() const;
|
||||||
void SetCloneOf(const std::string& cloneOf);
|
void SetCloneOf(const std::string& cloneOf);
|
||||||
bool operator<(const Item& rhs);
|
|
||||||
bool operator>(const Item& rhs);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string Launcher;
|
std::string Launcher;
|
||||||
|
|||||||
@@ -343,32 +343,30 @@ void Configuration::GetMediaPropertyAbsolutePath(std::string collectionName, std
|
|||||||
{
|
{
|
||||||
std::string key = "media." + collectionName + "." + mediaType;
|
std::string key = "media." + collectionName + "." + mediaType;
|
||||||
|
|
||||||
if(!GetPropertyAbsolutePath(key, value))
|
if(GetPropertyAbsolutePath(key, value)) { return; }
|
||||||
{
|
|
||||||
std::string baseMediaPath;
|
|
||||||
if(!GetPropertyAbsolutePath("baseMediaPath", baseMediaPath))
|
|
||||||
{
|
|
||||||
baseMediaPath = "Media";
|
|
||||||
}
|
|
||||||
|
|
||||||
value = baseMediaPath + "/" + collectionName + "/" + Utils::UppercaseFirst(Utils::ToLower(mediaType));
|
std::string baseMediaPath;
|
||||||
|
if(!GetPropertyAbsolutePath("baseMediaPath", baseMediaPath))
|
||||||
|
{
|
||||||
|
baseMediaPath = "Media";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value = baseMediaPath + "/" + collectionName + "/" + Utils::ToLower(mediaType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::GetCollectionAbsolutePath(std::string collectionName, std::string &value)
|
void Configuration::GetCollectionAbsolutePath(std::string collectionName, std::string &value)
|
||||||
{
|
{
|
||||||
std::string key = "collections." + collectionName + ".list.path";
|
std::string key = "collections." + collectionName + ".list.path";
|
||||||
|
|
||||||
if(!GetPropertyAbsolutePath(key, value))
|
if(GetPropertyAbsolutePath(key, value)) { return; }
|
||||||
{
|
|
||||||
std::string baseItemPath;
|
|
||||||
if(!GetPropertyAbsolutePath("baseItemPath", baseItemPath))
|
|
||||||
{
|
|
||||||
baseItemPath = "Assets";
|
|
||||||
}
|
|
||||||
|
|
||||||
value = baseItemPath + "/" + collectionName;
|
std::string baseItemPath;
|
||||||
|
if(!GetPropertyAbsolutePath("baseItemPath", baseItemPath))
|
||||||
|
{
|
||||||
|
baseItemPath = "Assets";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value = baseItemPath + "/" + collectionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ std::string Utils::UppercaseFirst(std::string str)
|
|||||||
if(str.length() > 0)
|
if(str.length() > 0)
|
||||||
{
|
{
|
||||||
std::locale loc;
|
std::locale loc;
|
||||||
str[0] = std::tolower(str[0], loc);
|
str[0] = std::toupper(str[0], loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
|||||||
Reference in New Issue
Block a user