bugfix: creating wav file on first run

We need to ensure the save dir exists. But it only gets created in calls
to love.filesystem.
This commit is contained in:
Kartik K. Agaram 2023-03-19 13:34:17 -07:00
parent d94dd8671e
commit be2335a15c
1 changed files with 4 additions and 1 deletions

View File

@ -23,8 +23,11 @@ wav = {
if type(filename) ~= "string" then
error("invalid function parameter, expected string filename", 2)
end
local absolute_path = love.filesystem.getSaveDirectory()..'/'..filename
-- ensure directory exists
love.filesystem.write(absolute_path, '')
-- Audio file handle
local file = io.open(love.filesystem.getSaveDirectory()..'/'..filename, "wb")
local file = io.open(absolute_path, "wb")
if not file then
error(string.format("couldn't open file %q", filename), 2)
end