npm install r-file-system
import RFile from 'r-file-system';
var fileSystem = new RFile('my file system');
in this case 'my file system' is file system name. if a file system with this name is exist, it will loaded. but if not exist it will created.
var file = {name:'mohammad',family:'feiz',age:34}
fileSystem.write(file,'file1')
in this code we want write an object(file) width defined name('file1') in file system. if in file system , there is a file with this name, this function will returned false if you want to write this file with this name anyway,you can call update function.
var file = {name:'mohammad',family:'feiz',age:34}
fileSystem.update(file,'file1')
in this code we want update a file by name = 'file1'. if in file system there is not a file with this name, this function will returned false. else a file by name = 'file1' will be updated.
var file = fileSystem.read('file1');
in this code we want to read a file by name = 'file1'. if in file system there is not a file with this name, this function will returned false.
var allFiles = fileSystem.remove('file1');
in this code we want to remove a file by name = 'file1'. if in file system there is not a file with this name, this function will returned false. else, after removing file this function will return all files array.
var exist = fileSystem.isExist('file1');
if in file system there is a file with name = 'file', this function will returned true , else false
fileSystem.removeAll();
var state = fileSystem.rename('file1','new name');
in this code we want to change name of a file by name = 'file1' to 'new name'. if there is not a file by name = 'file1', this function will returned 'file not found'. if a file by name = 'new name' is exist, this function will returned 'exist name'. else if all things is ok this function will returned true.
fileSystem.clear();
after call this function, the file system will be removed from localStorage(clearStorage).
var allFiles = fileSystem.getAll()
get all files in file system as an array.
fileSystem.duplicate('file1','new name');
create a copy from file by name = 'file1' to a file by name = 'new name'. if you dont send 'new name', the new file name will be 'file1 - copy'. this function will nothing returned.
fileSystem.removeEmpty();
this code will removed all empty file or garbages.