Running some test and figured out that there are at least two possibilities to check if a file/entry exists
s = require('Storage'); file = { name : 'ABC', exist : 0}; // variant I if (s.list().find(e => (e == file.name))) { file.exist = 1; console.log(file.name,"exists"); } else { file.exist = 1; console.log(file.name,"is missing "); } // variant II if (s.read(file.name)) { file.exist = 1; console.log(file.name,"exists"); } else { file.exist = 1; console.log(file.name,"is missing "); }
Are there any pros and cons for those variants?
@MaBe started
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.
Running some test and figured out that there are at least two possibilities to check if a file/entry exists
Are there any pros and cons for those variants?