Добавлен метод readFiles

This commit is contained in:
Book Pauk
2019-10-28 20:31:06 +07:00
parent 5f04c24187
commit f741bc818d

View File

@@ -57,7 +57,20 @@ class MegaStorage {
await fs.writeFile(nameHash.descPath, JSON.stringify(desc, null, 2));
}
async readFiles(callback) {
async readFiles(callback, dir) {
if (!callback)
return;
if (!dir)
dir = this.megaStorageDir;
const files = await fs.readdir(dir, { withFileTypes: true });
for (const file of files) {
const found = path.resolve(dir, file.name);
if (file.isDirectory())
await this.readFiles(callback, found);
else
callback(found);
}
}
async stopReadFiles() {