Added missed methods for desktop implementation: mkdir, readDir, unlink

This commit is contained in:
Volodymyr Kozieiev 2018-07-14 17:07:14 +03:00
parent 6919f3e62a
commit e60e5cd606
No known key found for this signature in database
GPG Key ID: 1F706640AAF07516
1 changed files with 24 additions and 4 deletions

View File

@ -53,7 +53,14 @@ QVariantMap RNFSManager::constantsToExport() {
}
void RNFSManager::readDir(QString dirPath, const ModuleInterface::ListArgumentBlock& resolve, const ModuleInterface::ListArgumentBlock& reject) {
Q_D(RNFSManager);
QDir dir(dirPath);
if (!dir.exists()) {
reject(d->bridge, QVariantList());
return;
}
resolve(d->bridge, QVariantList{{dir.entryList()}});
}
void RNFSManager::exists(QString filepath, const ModuleInterface::ListArgumentBlock& resolve, const ModuleInterface::ListArgumentBlock& reject) {
@ -91,11 +98,27 @@ void RNFSManager::write(QString filepath, QString base64Content, int position, c
}
void RNFSManager::unlink(QString filepath, const ModuleInterface::ListArgumentBlock& resolve, const ModuleInterface::ListArgumentBlock& reject) {
Q_D(RNFSManager);
QDir dir(filepath);
if(dir.exists()) {
dir.rmpath(filepath);
resolve(d->bridge, QVariantList{});
return;
}
QFile file(filepath);
if(file.exists()) {
file.remove();
resolve(d->bridge, QVariantList{});
return;
}
}
void RNFSManager::mkdir(QString filepath, QVariantMap options, const ModuleInterface::ListArgumentBlock& resolve, const ModuleInterface::ListArgumentBlock& reject) {
Q_D(RNFSManager);
QDir dir = QDir::root();
dir.mkpath(filepath);
resolve(d->bridge, QVariantList{});
}
void RNFSManager::readFile(QString filepath, const ModuleInterface::ListArgumentBlock& resolve, const ModuleInterface::ListArgumentBlock& reject) {
@ -202,6 +225,3 @@ bool RNFSManager::removeRecursively(const QString& path) {
return QFile::remove(path);
}
}