Simulator: Option to restrict outputs for playdate.simulator.writeToFile

It would be nice if the simulator had options to disable all outputs from playdate.simulator.writeToFile, or limit outputs to always fall in a certain directory.

On Windows, this is something of an inconvenience since the default output location appears to be the PlaydateSDK directory. On other systems, there might be some exploit enabled due to the ability to create arbitrary files.

  • Suppose there is some software that requires "some_file.lock" to be created before accessing "some_file", the simulator could block that by writing to "some_file.lock/output.png", since it will silently create parent directories automatically.

  • There may be some PNG files where having them in your home directory will get you in trouble.

On the plus side, the console will log what the simulator tried to write, although users need to know to look there. My worry is that people just running suspicious Playdate games they downloaded from random places might not notice.

Sounds like a bug.

Are you specifying a bundle ID in the pdxinfo file of your project? With that file reads/writes should point the data folder.

I don't have a pdxinfo file, just a main.lua that did roughtly this:

import "CoreLibs/graphics"
playdate.simulator.writeToFile(gfx.image.new(640, 480), "test/output.png")

We do restrict writing to inside the playdate SDK folder currently. As Matt mentioned, it will also default to a data folder with reverse dns style naming if you have a pdxinfo file with a bundle ID. I suppose we could restrict writing further and not allow writing outside the games data folder and if there is no pdxinfo it could fail; we'd have to make sure that didn't have any unintended consequences.