Filesystem
Neutralino's Filesystem API: https://neutralino.js.org/docs/api/filesystem
fs.read(file, binary = false)
Arguments:
Name
Description
file: string
Path to the file
binary: boolean = false
If true, then will return ArrayBuffer object. Otherwise - string
Returns Promise<string|ArrayBuffer>
import { fs } from '@empathize/framework';
// print 'my_file.txt' content to the console
fs.read('my_file.txt').then(console.log);
fs.write(file, data)
import { fs } from '@empathize/framework';
// Write 'Hello, World!' to 'my_file.txt'
fs.write('my_file.txt', 'Hello, World!');
fs.exists(path)
import { fs } from '@empathize/framework';
// Check if 'my_file.txt' exists
fs.exists('my_file.txt').then(console.log);
fs.stats(path)
import { fs } from '@empathize/framework';
// Get 'my_file.txt' file stats
fs.stats('my_file.txt').then((stats) => {
console.log(`Type: ${stats.type}`); // will be 'file' or 'directory'
console.log(`Size: ${stats.size} bytes`);
});
fs.remove(file)
import { fs } from '@empathize/framework';
// Remove 'my_file.txt'
fs.remove('my_file.txt');
// Remove 'my_folder'
fs.remove('my_folder');
fs.files(path)
import { fs } from '@empathize/framework';
// List files and folders inside of the 'my_folder'
fs.files('my_folder').then((files) => {
for (const file of files)
console.log(`[${file.type}] my_folder/${file.name}`);
});
fs.mkdir(directory)
import { fs } from '@empathize/framework';
// Create 'my_folder_1/my_folder_2' directory (recursively)
fs.mkdir('my_folder_1/my_folder_2');
fs.copy(from, to)
import { fs } from '@empathize/framework';
// Copy 'from/my_file.txt' as 'to/my_file.txt'
fs.copy('from/my_file.txt', 'to/my_file.txt');
// Copy 'from/my_folder' as 'to/my_folder'
fs.copy('from/my_folder', 'to/my_folder');
fs.move(from, to)
import { fs } from '@empathize/framework';
// Move 'from/my_file.txt' as 'to/my_file.txt'
fs.move('from/my_file.txt', 'to/my_file.txt');
// Move 'from/my_folder' as 'to/my_folder'
fs.move('from/my_folder', 'to/my_folder');
Last updated