From 399225a12bf90859390d0b4782d8a9e738277ed5 Mon Sep 17 00:00:00 2001 From: Abdullah Alfaraj Date: Fri, 10 Mar 2023 14:21:30 +0300 Subject: [PATCH] get all json entries in a folder --- utility/io.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utility/io.js b/utility/io.js index 136df14..d574d90 100644 --- a/utility/io.js +++ b/utility/io.js @@ -659,6 +659,22 @@ class IOJson { ) return settings_json } + + static async getJsonEntries(doc_entry) { + let entries = await doc_entry.getEntries() + const json_entries = entries.filter( + (e) => e.isFile && e.name.toLowerCase().includes('.json') // must be a file and has the of the type .json + ) + console.log('json_entries: ', json_entries) + // .forEach((e) => console.log(e.name)) + return json_entries + } + static async deleteFile(doc_entry, file_name) { + try { + const file_entry = await doc_entry.getEntry(file_name) + file_entry.delete() + } catch (e) {} + } } module.exports = {