FuseJS/FileSystem Module (JS)
Provides an interface to the file system.
var FileSystem = require("FuseJS/FileSystem");
Using the asynchronous Promise based functions is recommended to keep your UI responsive, although synchronous variants are also available if preferred.
When saving files private to the application you can use the dataDirectory
property
as a base path.
Example
This example writes a text to a file, and then reads it back:
var FileSystem = require("FuseJS/FileSystem");
var path = FileSystem.dataDirectory + "/" + "testfile.tmp";
FileSystem.writeTextToFile(path, "hello world")
.then(function() {
return FileSystem.readTextFromFile(path);
})
.then(function(text) {
console.log("The read file content was: " + text);
})
.catch(function(error) {
console.log("Unable to read file due to error:" + error);
});
Location
- Namespace
- Fuse.FileSystem
- Package
- Fuse.FileSystem 2.9.1
Interface of FileSystemModule
appendTextToFileSync(filename) js
copy(source, destination) js
copySync(source, destination) js
createDirectory(path) js
createDirectorySync(path) js
exists(path) js
existsSync(path) js
FileSystemModule Constructor uno
androidPaths : Dictionary<string, string> js
cacheDirectory : string js
dataDirectory : string js
getDirectoryInfo(path) js
getDirectoryInfoSync(path) js
getFileInfo(path) js
getFileInfoSync(path) js
iosPaths : Dictionary<string, string> js
listDirectories(path) js
listDirectoriesSync(path) js
listEntries(path) js
listEntriesSync(path) js
listFiles(path) js
listFilesSync(path) js
move(source, destination) js
moveSync(source, destination) js
readBufferFromFile(filename) js
readBufferFromFileSync(filename) js
readTextFromFile(filename) js
readTextFromFileSync(filename) js
remove(path) js
removeSync(path) js
writeBufferToFile(filename, data) js
writeBufferToFileSync(filename, data) js
writeTextToFile(filename, text) js
writeTextToFileSync(filename, text) js
Inherited from NativeModule
AddMember(NativeMember) uno
Reset : EventHandler (object, EventArgs) ux
Inherited from Module
Dispose uno
Evaluate(Context, ModuleResult) uno
Evaluate(Context, string) : ModuleResult uno
Evaluated : EventHandler (object, EventArgs) ux
EvaluateExports(Context, string) : object uno
GetFile : FileSource uno
Returns the file source that will be watched by the Context for changes in Fuse preview. Override in subclasses and return correct file source to support live updates in Fuse preview.