This commit is contained in:
sorlinv
2026-02-20 19:27:27 +01:00
commit b556cce88c
23 changed files with 8182 additions and 0 deletions

52
src/main/PathResolver.js Normal file
View File

@@ -0,0 +1,52 @@
const path = require("path");
const fs = require("fs");
const STR_EXE_NAME = process.platform === "win32" ? "blender.exe" : "blender";
const PathResolver = {
_str_blender_path: null,
get_blender_path: () => {
if (PathResolver._str_blender_path) {
return PathResolver._str_blender_path;
}
// Mode package : resources/blender/
let str_resources_dir = path.join(process.resourcesPath, "blender");
let str_found = PathResolver._find_in_dir(str_resources_dir);
if (str_found) {
PathResolver._str_blender_path = str_found;
return str_found;
}
// Mode dev : racine projet/blender/
let str_dev_dir = path.join(__dirname, "..", "..", "blender");
str_found = PathResolver._find_in_dir(str_dev_dir);
if (str_found) {
PathResolver._str_blender_path = str_found;
return str_found;
}
// Fallback : PATH systeme
PathResolver._str_blender_path = "blender";
return "blender";
},
_find_in_dir: (str_dir) => {
if (!fs.existsSync(str_dir)) {
return null;
}
let list_entries = fs.readdirSync(str_dir);
for (let str_entry of list_entries) {
let str_exe = path.join(str_dir, str_entry, STR_EXE_NAME);
if (fs.existsSync(str_exe)) {
return str_exe;
}
}
return null;
},
};
module.exports = PathResolver;