File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Launchers/retro-esp32/main Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1639
1639
char file [256 ] = "/sd/odroid/data" ;
1640
1640
sprintf (file , "%s/%s" , file , RETROESP_FOLDER );
1641
1641
sprintf (file , "%s/%s" , file , RECENT_FILE );
1642
+
1643
+ bool duplicate = false;
1642
1644
FILE * f ;
1643
1645
f = fopen (file , "a+" );
1644
1646
if (f ) {
1645
- // printf("\nADDING: %s to %s", favorite, file);
1646
- fprintf (f , "%s\n" , recent );
1647
+ printf ("\nCHECKING: %s\n" , recent );
1648
+ char line [256 ];
1649
+ while (fgets (line , sizeof (line ), f )) {
1650
+ char * ep = & line [strlen (line )- 1 ];
1651
+ while (* ep == '\n' || * ep == '\r' ){* ep -- = '\0' ;}
1652
+ if (strcmp (recent , line ) == 0 ) {
1653
+ duplicate = true;
1654
+ }
1655
+ }
1656
+ }
1657
+ if (!duplicate ) {
1658
+ fprintf (f , "%s\n" , recent );
1647
1659
}
1648
1660
fclose (f );
1649
1661
// printf("\n----- %s END -----\n", __func__);
You can’t perform that action at this time.
0 commit comments