1'use strict'; 2 3function writeSync(path, data, options) { 4 if (!path || !data) { 5 throw new Error('params is invalid'); 6 } 7 options = options || {flag: 'w'}; 8 __native.FS.write(path, data, options); 9} 10 11function readSync(path) { 12 if(!path) { 13 throw new Error("invalid params"); 14 } 15 var content = __native.FS.read(path); 16 if (!content) { 17 throw 'file open error'; 18 } 19 20 return content; 21} 22 23function unlinkSync(path) { 24 if(!path) { 25 throw new Error("invalid params"); 26 } 27 __native.FS.delete(path); 28} 29 30function totalSize() { 31 return __native.FS.totalsize(); 32} 33 34function usedSize() { 35 return __native.FS.usedsize(); 36} 37 38function freeSize() { 39 return __native.FS.freesize(); 40} 41 42module.exports = { 43 writeSync, 44 readSync, 45 unlinkSync, 46 totalSize, 47 usedSize, 48 freeSize 49}