From ed364a58fb0292b702e79cd39c779d65ebfc567a Mon Sep 17 00:00:00 2001 From: Ken Bynell Date: Wed, 22 May 2024 02:30:26 -0500 Subject: [PATCH] FIND_FILES update --- commands/debug2.js | 9 ++++++++- support_files/lslib_utils.js | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/commands/debug2.js b/commands/debug2.js index 30afefc2..9de4c3e0 100644 --- a/commands/debug2.js +++ b/commands/debug2.js @@ -9,6 +9,8 @@ const { getConfig } = require('../support_files/config'); const { CREATE_LOGGER, raiseError, raiseInfo } = require('../support_files/log_utils.js'); const bg3mh_logger = CREATE_LOGGER(); +const { FIND_FILES_v2, getFormats } = require('../support_files/lslib_utils.js'); + const debug2 = vscode.commands.registerCommand('bg3-mod-helper.debug2Command', async function () { const config = getConfig(); const localizationPath = path.join(config.rootModPath, 'Localization'); @@ -16,7 +18,12 @@ const debug2 = vscode.commands.registerCommand('bg3-mod-helper.debug2Command', a raiseInfo(`half of your cpu's cores: ${halfCoreCount}`); - + try { + console.log(FIND_FILES_v2(".lsx")); + } + catch (err) { + console.error(err); + } // after you are through with this command, the following line must be uncommented and the only thing left for this file to be considered cleaned up. diff --git a/support_files/lslib_utils.js b/support_files/lslib_utils.js index 80c592dc..a75d0dc4 100644 --- a/support_files/lslib_utils.js +++ b/support_files/lslib_utils.js @@ -6,6 +6,8 @@ const path = require('path'); const fs = require('fs'); const vscode = require('vscode'); +const findFiles = vscode.workspace.findFiles; +const parse = vscode.Uri.parse; // loads the api @@ -168,6 +170,13 @@ function FIND_FILES(filesPath, targetExt = getFormats().lsf, isRecursive = true) } +// beautiful. still needs dll handling in lslib_utils though +async function FIND_FILES_v2(targetExt = getFormats().lsf, filesPath = '**/*') { + const filesList = (await findFiles(filesPath + targetExt)).map(file => file.path); + return FILTER_PATHS(filesList); +} + + function FILTER_PATHS(filesPath) { let excludedFiles = getConfig().excludedFiles; if (Array.isArray(filesPath)) { @@ -232,4 +241,4 @@ function moveFileAcrossDevices(sourcePath, destPath, raiseError) { const LSLIB = LOAD_LSLIB(); -module.exports = { LSLIB, FIND_FILES, FILTER_PATHS, getFormats, moveFileAcrossDevices, baseNamePath, dirSeparator, compatRootModPath }; \ No newline at end of file +module.exports = { LSLIB, FIND_FILES, FIND_FILES_v2, FILTER_PATHS, getFormats, moveFileAcrossDevices, baseNamePath, dirSeparator, compatRootModPath }; \ No newline at end of file