cordova-FileUtil
Cordova File Util
const cordovaFileUtil = CordovaFileUtil.getInstance();
const dirEntry = cordovaFileUtil.getDirEntry(cordova.file.dataDirectory + 'testFolder');
const fileEntry = cordovaFileUtil.getFileEntry('test.text', dirEntry);
const readData = cordovaFileUtil.read(fileEntry);
cordovaFileUtil.write(fileEntry, "test text");
cordovaFileUtil.remove('test.text', dirEntry);
cordovaFileUtil.removeDir(dirEntry);
Installation
For typical cordova projects, copy and use the code at cordovaFileUtil.js in this repository
https://github.com/Artifriends-inc/cordova-FileUtil
How to install with Frontle
$ frontle install-original cordova-fileutil
Function
getInstance()
Get "CordovaFileUtil" object
Only one object is created using a single-tone pattern
const cordovaFileUtil = CordovaFileUtil.getInstance();
getDirEntry(path, folderName, create = true)
Get folder entry, If the "create" option is true, a folder is created
const dirEntry = cordovaFileUtil.getDirEntry(cordova.file.dataDirectory + 'testFolder');
getFileEntry(fileName, dirEntry, create = true)
Get file entry, If the "create" option is true, a file is created
const fileEntry = cordovaFileUtil.getFileEntry('test.text', dirEntry);
read(fileEntry)
Reads file data
const readData = cordovaFileUtil.read(fileEntry);
write(fileName, writeData)
Write file data
cordovaFileUtil.write(fileEntry, "test text");
remove(fileName, dirEntry)
Remove file
cordovaFileUtil.remove('test.text', dirEntry);
removeDir(dirEntry)
Remove directory
cordovaFileUtil.removeDir(dirEntry);
People
The original author of cordova-fileutil is MushStory
License
MIT