I am trying out the Sorage module. The example in the documentation works fine on my board. However a small change in the code brought me to a problem:
I would start with an empty file of the required size and then populate the file with content:
var f = require("Storage");
f.write("a", "", 0, 20);
console.log("File-Size: ", f.read("a").length);
f.write("a","Hello",0);
f.write("a"," ",5);
f.write("a","World!!!",6);
print(f.read("a"));
This results in an error:
File-Size: 14
Uncaught Error: Too much data for file size
at line 1 col 18
f.write("a"," ",5);
^
Uncaught Error: Too much data for file size
at line 1 col 25
f.write("a","World!!!",6);
^
Hello
And another question: How to determine the size of a file without reading it? The file might be bigger than the available memory and the "list()" method just lists the file name.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I am trying out the Sorage module. The example in the documentation works fine on my board. However a small change in the code brought me to a problem:
I would start with an empty file of the required size and then populate the file with content:
This results in an error:
And another question: How to determine the size of a file without reading it? The file might be bigger than the available memory and the "list()" method just lists the file name.