Skip to content

Commit e120b61

Browse files
committed
Thu 5 Mar 2020 14:49:21 EST - fixes
1 parent 565ad02 commit e120b61

File tree

1 file changed

+14
-2
lines changed
  • Launchers/retro-esp32/main

1 file changed

+14
-2
lines changed

Launchers/retro-esp32/main/main.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,11 +1639,23 @@
16391639
char file[256] = "/sd/odroid/data";
16401640
sprintf(file, "%s/%s", file, RETROESP_FOLDER);
16411641
sprintf(file, "%s/%s", file, RECENT_FILE);
1642+
1643+
bool duplicate = false;
16421644
FILE *f;
16431645
f = fopen(file, "a+");
16441646
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);
16471659
}
16481660
fclose(f);
16491661
// printf("\n----- %s END -----\n", __func__);

0 commit comments

Comments
 (0)