See Script Reference for FileManager.
1. Directory or file?
Is there a way to determine whether a path is a directory or a file? This would be useful for example when using listContents to walk recursively down through a directory tree.
2. Extending the class
In JavaScript both built-in and custom classes can be subclassed with the extends keyword. Why does this not work for the FileManager class?
Cut-down example to illustrate:
class myFileManager extends FileManager {
BASEPATH() {
return this.basePath
}
}
let fm = myFileManager.createCloud();
alert(fm.BASEPATH());
This gives
Script Error: TypeError: fm.BASEPATH is not a function. (In ‘fm.BASEPATH()’, ‘fm.BASEPATH’ is undefined)
3. lastError
Why is lastError undefined after a failure to write a file in a nonexistent directory?
let fm = FileManager.createCloud();
let path = "/deliberately/nonexisting/path.txt";
let success = fm.writeString(path, "Hello world");
if (!success) throw new Error(
`Could not write ${path}: success=${success} error=${fm.lastError}`
);
The error message says “…success=false error=undefined”.