|
|
|
@ -157,35 +157,37 @@ class FileProvider { |
|
|
|
|
* @param {*} path is the folder to be removed |
|
|
|
|
*/ |
|
|
|
|
remove (path) { |
|
|
|
|
path = this.removePrefix(path) |
|
|
|
|
if (window.remixFileSystem.existsSync(path)) { |
|
|
|
|
const stat = window.remixFileSystem.statSync(path) |
|
|
|
|
try { |
|
|
|
|
if (!stat.isDirectory()) { |
|
|
|
|
return this.removeFile(path) |
|
|
|
|
} else { |
|
|
|
|
const items = window.remixFileSystem.readdirSync(path) |
|
|
|
|
if (items.length !== 0) { |
|
|
|
|
items.forEach((item, index) => { |
|
|
|
|
const curPath = `${path}/${item}` |
|
|
|
|
if (window.remixFileSystem.statSync(curPath).isDirectory()) { // delete folder
|
|
|
|
|
this.remove(curPath) |
|
|
|
|
} else { // delete file
|
|
|
|
|
this.removeFile(curPath) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (window.remixFileSystem.readdirSync(path).length === 0) window.remixFileSystem.rmdirSync(path, console.log) |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
path = this.removePrefix(path) |
|
|
|
|
if (window.remixFileSystem.existsSync(path)) { |
|
|
|
|
const stat = window.remixFileSystem.statSync(path) |
|
|
|
|
try { |
|
|
|
|
if (!stat.isDirectory()) { |
|
|
|
|
resolve(this.removeFile(path)) |
|
|
|
|
} else { |
|
|
|
|
// folder is empty
|
|
|
|
|
window.remixFileSystem.rmdirSync(path, console.log) |
|
|
|
|
const items = window.remixFileSystem.readdirSync(path) |
|
|
|
|
if (items.length !== 0) { |
|
|
|
|
items.forEach((item, index) => { |
|
|
|
|
const curPath = `${path}/${item}` |
|
|
|
|
if (window.remixFileSystem.statSync(curPath).isDirectory()) { // delete folder
|
|
|
|
|
this.remove(curPath) |
|
|
|
|
} else { // delete file
|
|
|
|
|
this.removeFile(curPath) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (window.remixFileSystem.readdirSync(path).length === 0) window.remixFileSystem.rmdirSync(path, console.log) |
|
|
|
|
} else { |
|
|
|
|
// folder is empty
|
|
|
|
|
window.remixFileSystem.rmdirSync(path, console.log) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log(e) |
|
|
|
|
return resolve(false) |
|
|
|
|
} |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log(e) |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true |
|
|
|
|
return resolve(true) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
removeFile (path) { |
|
|
|
|