I have a bookmark “Textastic local web” pointing at Files On My iPad/Textastic/web/. My code
let fm = FileManager.createForBookmark(
Bookmark.findOrCreate("Textastic local web")
);
let success = fm.writeString("/web/testfile.txt", "xyzzy");
if (!success) throw new Error(
`Could not write ${path}: success=${success} error=${fm.lastError}`
);
has an error in it: it includes “web/” in the file name even though the web/ subfolder was already part of the bookmark. But it took me a long time to diagnose this because the error message received was inaccurate. It said
Script Error: Error: Could not write /web/testfile.html: success=false error=FileManger.writeString: File error at /web/testfile.html: The file “testfile.html” doesn’t exist.
Indeed the file doesn’t exist: it hasn’t been written yet! The error message should say instead that the folder web/ does not exist.
There’s also a typo: “FileManger”.