files
files
provides the following functionalities:
- Read and write files to and from the local file system
- Monitor files for changes
- Drag files
Methods
loadTextFile(filename)
filename
string - Path to the file to be loaded.
Load the contents of filename
.
Returns Promise<string>
- Resolves with the contents of the file.
saveTextFile(filename, content)
filename
string - Save the file to this path.content
string - The text content to be written to the file.
Save content
to filename
.
loadBinaryFile(filename)
filename
string - Path to the file to be loaded.
Load the contents of filename
as binary data.
Returns Promise<ArrayBuffer>
- Resolves with an ArrayBuffer containing the contents of the file.
saveBinaryFile(filename, content)
filename
string - Save the file to this path.content
ArrayBuffer - The binary data to be written to the file.
Save content
to filename
.
watchFile(filename, [callback])
filename
string - Path to the file to be watchedcallback
Function (optional) - It's called when changes happens to the file.
removeWatch(filename)
filename
string - Removefilename
from the watched files.
removeAllWatches()
Remove all watched files.
startDrag(filename)
filename
string - Path to file to be dragged.
Events
'file-changed'
Event triggered when a watched file changes. The parameter is the path to the file that changed.