You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
703 B
JavaScript
37 lines
703 B
JavaScript
class Model {
|
|
constructor() {}
|
|
|
|
async dirList(dir = "/") {
|
|
let list = await pfs.readdir(dir);
|
|
|
|
for (let u = 0; u < list.length; u++) {
|
|
let re = /^\..*$/;
|
|
|
|
if (re.test(list[u])) {
|
|
list.splice(u, 1)
|
|
u--
|
|
}
|
|
}
|
|
|
|
|
|
let dirtree = [dir];
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
dirtree[i + 1] = list[i];
|
|
let itemStat = await pfs.stat(dirtree[0] + dirtree[i+1]);
|
|
if (itemStat.isDirectory()) {
|
|
dirtree[i+1] = await this.dirList(dirtree[0] + dirtree[i+1] + "/");
|
|
}
|
|
}
|
|
|
|
return dirtree;
|
|
}
|
|
|
|
async dirTree(dir = "/") {
|
|
var tree = await this.dirList(dir);
|
|
|
|
console.log(tree);
|
|
return tree;
|
|
}
|
|
}
|