When I try to save a file that has a folder in its path...
var file = File.new()
file.open("user://data/save_game.txt", File.WRITE)
file.store_string("TEST")
file.close()
...I get an error:
ERROR: File must be opened before use.
onPrintError @ index.js:400
putchar @ index.js:9
write @ index.js:9
write @ index.js:9
doWritev @ index.js:9
_fdwrite @ index.js:9
$func24319 @ 03499712:0x6d99d3
$func7980 @ 03499712:0x21305c
$func8162 @ 03499712:0x21fb4b
$func25950 @ 03499712:0x72f85b
$func7235 @ 03499712:0x1df568
$func25954 @ 03499712:0x72f9d2
$func25948 @ 03499712:0x72f764
$func637 @ 03499712:0x28393
$func25073 @ 03499712:0x712a15
$func13712 @ 03499712:0x3e02c7
$func7727 @ 03499712:0x2021b8
$func7758 @ 03499712:0x203dbd
$func2740 @ 03499712:0xade46
$func11815 @ 03499712:0x35f6d8
$func23092 @ 03499712:0x6bbce0
$func1341 @ 03499712:0x57cd2
$func976 @ 03499712:0x3cab1
$func20041 @ 03499712:0x576719
$func20041 @ 03499712:0x5766c1
$func5660 @ 03499712:0x16f085
$func40766 @ 03499712:0xa95d64
$gk @ 03499712:0x4c67ac
$hk @ 03499712:0x6cbb4b
Module.main @ index.js:9
callMain @ index.js:9
(anonymous) @ index.js:736
(anonymous) @ index.js:731
Promise.then (async)
(anonymous) @ index.js:730
Promise.then (async)
start @ index.js:709
(anonymous) @ index.js:772
Promise.then (async)
startGame @ index.js:771
(anonymous) @ (index):289
setTimeout (async)
(anonymous) @ (index):286
setTimeout (async)
(anonymous) @ (index):283
Promise.then (async)
(anonymous) @ (index):280
(anonymous) @ (index):318
Show 3 more frames
00:32:55.144 index.js:400 at: storestring (core/bind/core_bind.cpp:2182) - Condition "!f" is true.
I also previously tried creating the folder...
var dir = Directory.new()
dir.open("user://data/")
dir.close()
... the error is still the same.
What did I forget to do?