Unlink() gives "permission denied" in C Api in Windows simulator

Calling playdate->file->unlink() on a file in the game's data directory, that we previously created with playdate->file->open(), will fail with playdate->file->geterr() reporting "permission denied".

I see this for all attempts to delete things, with or without recursive being set to true in unlink()

Where did you install the SDK at? Make sure you have read/write permissions, but I'll look into this tomorrow.

I don't think system permissions are a problem, as creating files works okay. And it's located in my windows user's Documents folder. Thanks for looking!

OK, this is working for me. That said, you need to make sure you close() the file before you try and unlink() it otherwise it will be reported as busy.

I am pretty sure I am calling close but let me double check. Thank you!

Ok I tried it again, and making a file and delete it does work. This does not though:

unlink("foo", 1);


unlink("foo", 0);

unlink() says it should work on a folder, at least when recursive is 1. It's not clear if it should work on an empty folder with recursive being 0:

Deletes the file at path . Returns 0 on success, or -1 in case of error. If recursive is 1 and the target path is a folder, this deletes everything inside the folder (including folders, folders inside those, and so on) as well as the folder itself.

1 Like

Thanks for the additional information. I've fixed unlink not working with directories for the next release.

1 Like