Save file path framework development advice

I hope this is the right place to seek this kind of advice. I’m trying to figure out how hard it would be to fix this GitHub issue where games with the same titles on different systems can overwrite each other’s save files.

I think a good way of fixing this could be to create a setting similar to the “Sort saves by core” option, but make it “Sort saves by content directory option”. I would think implementing this would be very similar to how the sorting by cores is currently done, since the way that seems to work is Retroarch looks to where you currently have your saves set to go, and appends a new folder after that which is named after the core.

But I’m having trouble getting started. I’ve been using Github to search the libretro/Retroarch repo to figure out how the saves framework works but am having no luck. I started by searching for strings in the logs and found the variable storing the message hash for what gets displayed when the log reports we are redirecting a save. This is: MSG_REDIRECTING_SAVEFILE_TO. The problem is, when I search for this variable name it’s only found in other message header files.

I was expecting to find it referenced somewhere where Retroarch is actually saving a file. Would anybody be able to point me in the right direction of where to start searching in the code? Thanks!

[UPDATE] I think I answered my own question - the place to look for file saving is in retroarch.c The reason I was having trouble is this file is huge (>1 MB) and GitHub code search doesn’t search over files that large.

Yeah, the giant retroarch.c is hopefully temporary while some things are redesigned and reorganized. It’s a problem, though, for sure.

Github’s search is awful, though. I very much recommend cloning the codebase and then grepping through it instead.