mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-07 20:00:47 +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 "../Database/Configuration.h"
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
CollectionInfo::CollectionInfo(std::string name,
|
||||
std::string listPath,
|
||||
@@ -88,5 +89,15 @@ std::vector<Item *> *CollectionInfo::GetItems()
|
||||
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 GetExtensions() const;
|
||||
std::vector<Item *> *GetItems();
|
||||
void SortItems();
|
||||
void GetExtensions(std::vector<std::string> &extensions);
|
||||
|
||||
private:
|
||||
static bool ItemIsLess(Item const *lhs, Item const *rhs);
|
||||
|
||||
std::string Name;
|
||||
std::string ListPath;
|
||||
std::string Extensions;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <dirent.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
CollectionInfoBuilder::CollectionInfoBuilder(Configuration &c, MetadataDatabase &mdb)
|
||||
: Conf(c)
|
||||
@@ -78,6 +79,33 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
|
||||
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)
|
||||
{
|
||||
DIR *dp;
|
||||
@@ -89,6 +117,10 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||
std::string includeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Include.txt";
|
||||
std::string excludeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Exclude.txt";
|
||||
std::string launcher;
|
||||
|
||||
|
||||
ImportBasicList(info, includeFile, includeFilter);
|
||||
ImportBasicList(info, excludeFile, excludeFilter);
|
||||
|
||||
std::vector<std::string> extensions;
|
||||
std::vector<std::string>::iterator extensionsIt;
|
||||
@@ -96,6 +128,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||
info->GetExtensions(extensions);
|
||||
|
||||
(void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher);
|
||||
Logger::Write(Logger::ZONE_ERROR, "CollectionInfoBuilder", "Check path " + includeFile);
|
||||
|
||||
dp = opendir(path.c_str());
|
||||
|
||||
@@ -138,7 +171,9 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
|
||||
|
||||
info->SortItems();
|
||||
|
||||
MetaDB.InjectMetadata(info);
|
||||
|
||||
while(includeFilter.size() > 0)
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
|
||||
private:
|
||||
MetadataDatabase &MetaDB;
|
||||
bool ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list);
|
||||
bool ImportDirectory(CollectionInfo *info);
|
||||
Configuration &Conf;
|
||||
};
|
||||
|
||||
@@ -150,13 +150,3 @@ void Item::SetCloneOf(const std::string& 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);
|
||||
const std::string& GetCloneOf() const;
|
||||
void SetCloneOf(const std::string& cloneOf);
|
||||
bool operator<(const Item& rhs);
|
||||
bool operator>(const Item& rhs);
|
||||
|
||||
private:
|
||||
std::string Launcher;
|
||||
|
||||
Reference in New Issue
Block a user