cordova-FileUtil
This package makes it easy to use the "cordova-plugin-file" plug-in
import {CordovaFileUtil} from "../../browser_modules/cordova-fileutil/cordovaFileUtil.js";
const cordovaFileUtil = new CordovaFileUtil();
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
How to install from Frontle
$ frontle install cordova-fileutil
How to install from Web
For typical web projects, copy and use the code at cordovaFileUtil.js in below repositorys
https://github.com/Artifriends-inc/cordova-FileUtil (cordovaFileUtil.js)
Function
new CordovaFileUtil()
Get "CordovaFileUtil" object. only one object is created using a single-tone pattern
const cordovaFileUtil = new CordovaFileUtil();
cordovaFileUtil.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');
cordovaFileUtil.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(fileEntry, 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