3.0 - Accessing the Shared folder in the Simulator in C

I’ve been porting the Achievements Framework to C so I can use it in my pure-C game.

Achievements save their data in /Shared/Achievements//Achievements.json

I can open this path and create a file successfully on the device (after creating all the sub directories) and the Trophy Cabinet correctly sees my data.

However, if I use the same paths in the 3.0 Simulator on Windows, I end up with a Shared folder inside my game’s data folder - it seems to ignore the leading / for any playdate.file functions

Furthermore, it does work on Simulator if I use the path “../../Shared/Achievements/” (which doesn’t work on the device)

In a test game, if I write pd→file→open(“/Shared/Achievements/test.txt”) it correctly opens the file. Could you show us exactly what code you’re writing that isn’t working.

Ok - I’ve worked it out

This works as expected:

pd->file->mkdir("/Shared/foo");
pd->file->mkdir("/Shared/foo/bar");
SDFile* file = pd->file->open("/Shared/foo/bar/wibble.txt", kFileWrite);
pd->file->write(file, "Hello World\r\n", 14);
pd->file->close(file);

But this creates a folder called ‘shared’ inside my game’s data folder

pd->file->mkdir("/shared/foo");
pd->file->mkdir("/shared/foo/bar");
SDFile* file = pd->file->open("/shared/foo/bar/wibble.txt", kFileWrite);
pd->file->write(file, "Hello World\r\n", 14);
pd->file->close(file);

So it looks like whilst the filesystem is case insensitive, it’s only /Shared/ with the capital S that’s getting redirected to the correct location

1 Like

Ah, that is a good catch. Without looking, I’m 99% sure we’re just doing a literal string comparison here without taking the filesystem case into consideration.