@@ -718,6 +718,9 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
718
718
bool adding {true };
719
719
std::string name {file->getName ()};
720
720
std::string sysName {mEditingCollection };
721
+ #if defined(RETRODECK)
722
+ std::string gameEntry = name + " ^" + file->getFullPath ();
723
+ #endif
721
724
if (mIsEditingCustom ) {
722
725
SystemData* sysData {mEditingCollectionSystemData ->system };
723
726
@@ -774,10 +777,48 @@ const bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
774
777
std::string value {md->get (" favorite" )};
775
778
if (value == " false" ) {
776
779
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
777
799
}
778
800
else {
779
801
adding = false ;
780
802
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
781
822
}
782
823
783
824
file->getSourceFileData ()->getSystem ()->getIndex ()->addToIndex (
0 commit comments