mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-07 11:30:30 +02:00
Playlist save support
This commit is contained in:
@@ -42,29 +42,6 @@ CollectionInfo::~CollectionInfo()
|
||||
{
|
||||
// remove items from the subcollections so their destructors do not
|
||||
// delete the items since the parent collection will delete them.
|
||||
if(saveRequest)
|
||||
{
|
||||
std::string file = Utils::combinePath(Configuration::absolutePath, "collections", name, "playlists/favorites.txt");
|
||||
Logger::write(Logger::ZONE_INFO, "Collection", "Saving " + file);
|
||||
|
||||
std::ofstream filestream;
|
||||
try
|
||||
{
|
||||
filestream.open(file.c_str());
|
||||
std::vector<Item *> *saveitems = playlists["favorites"];
|
||||
for(std::vector<Item *>::iterator it = saveitems->begin(); it != saveitems->end(); it++)
|
||||
{
|
||||
filestream << (*it)->name << std::endl;
|
||||
}
|
||||
|
||||
filestream.close();
|
||||
}
|
||||
catch(std::exception &)
|
||||
{
|
||||
Logger::write(Logger::ZONE_ERROR, "Collection", "Save failed: " + file);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<CollectionInfo *>::iterator subit;
|
||||
for (subit = subcollections_.begin(); subit != subcollections_.end(); subit++)
|
||||
{
|
||||
@@ -94,6 +71,36 @@ CollectionInfo::~CollectionInfo()
|
||||
}
|
||||
}
|
||||
|
||||
bool CollectionInfo::Save()
|
||||
{
|
||||
bool retval = true;
|
||||
if(saveRequest)
|
||||
{
|
||||
std::string file = Utils::combinePath(Configuration::absolutePath, "collections", name, "playlists/favorites.txt");
|
||||
Logger::write(Logger::ZONE_INFO, "Collection", "Saving " + file);
|
||||
|
||||
std::ofstream filestream;
|
||||
try
|
||||
{
|
||||
filestream.open(file.c_str());
|
||||
std::vector<Item *> *saveitems = playlists["favorites"];
|
||||
for(std::vector<Item *>::iterator it = saveitems->begin(); it != saveitems->end(); it++)
|
||||
{
|
||||
filestream << (*it)->name << std::endl;
|
||||
}
|
||||
|
||||
filestream.close();
|
||||
}
|
||||
catch(std::exception &)
|
||||
{
|
||||
Logger::write(Logger::ZONE_ERROR, "Collection", "Save failed: " + file);
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string CollectionInfo::settingsPath() const
|
||||
{
|
||||
return Utils::combinePath(Configuration::absolutePath, "collections", name);
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
CollectionInfo(std::string name, std::string listPath, std::string extensions, std::string metadataType, std::string metadataPath);
|
||||
virtual ~CollectionInfo();
|
||||
std::string settingsPath() const;
|
||||
bool Save();
|
||||
void sortItems();
|
||||
void addSubcollection(CollectionInfo *info);
|
||||
bool hasSubcollections();
|
||||
|
||||
Reference in New Issue
Block a user