@@ -718,6 +718,9 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
718718 bool adding {true };
719719 std::string name {file->getName ()};
720720 std::string sysName {mEditingCollection };
721+ #if defined(RETRODECK)
722+ std::string gameEntry = name + " ^" + file->getFullPath ();
723+ #endif
721724 if (mIsEditingCustom ) {
722725 SystemData* sysData {mEditingCollectionSystemData ->system };
723726
@@ -774,10 +777,48 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
774777 std::string value {md->get (" favorite" )};
775778 if (value == " false" ) {
776779 md->set (" favorite" , " true" );
780+ #if defined(RETRODECK)
781+ std::ofstream outFile (" /tmp/retrodeck/favorites/to_add" , std::ios::app);
782+ if (outFile.is_open ()) {
783+ outFile << gameEntry << std::endl;
784+ outFile.close ();
785+ }
786+ std::ifstream inFile (" /tmp/retrodeck/favorites/to_remove" );
787+ std::ofstream tempFile (" /tmp/retrodeck/favorites/temp" );
788+ std::string line;
789+ while (std::getline (inFile, line)) {
790+ if (line != gameEntry) {
791+ tempFile << line << std::endl;
792+ }
793+ }
794+ inFile.close ();
795+ tempFile.close ();
796+ std::remove (" /tmp/retrodeck/favorites/to_remove" );
797+ std::rename (" /tmp/retrodeck/favorites/temp" , " /tmp/retrodeck/favorites/to_remove" );
798+ #endif
777799 }
778800 else {
779801 adding = false ;
780802 md->set (" favorite" , " false" );
803+ #if defined(RETRODECK)
804+ std::ofstream outFile (" /tmp/retrodeck/favorites/to_remove" , std::ios::app);
805+ if (outFile.is_open ()) {
806+ outFile << gameEntry << std::endl;
807+ outFile.close ();
808+ }
809+ std::ifstream inFile (" /tmp/retrodeck/favorites/to_add" );
810+ std::ofstream tempFile (" /tmp/retrodeck/favorites/temp" );
811+ std::string line;
812+ while (std::getline (inFile, line)) {
813+ if (line != gameEntry) {
814+ tempFile << line << std::endl;
815+ }
816+ }
817+ inFile.close ();
818+ tempFile.close ();
819+ std::remove (" /tmp/retrodeck/favorites/to_add" );
820+ std::rename (" /tmp/retrodeck/favorites/temp" , " /tmp/retrodeck/favorites/to_add" );
821+ #endif
781822 }
782823
783824 file->getSourceFileData ()->getSystem ()->getIndex ()->addToIndex (
0 commit comments