/** * Добавляет префикс корневой папки к каждому пути дерева. * * @param {{path: string, file?: File, children: Array}} root Узел дерева. * @param {string} prefix Путь выбранной папки, в которую попал узел. * @returns {object} Тот же узел после изменения путей. * * Для leaf-файлов создаётся новый File с обновлённым именем, чтобы метаданные * browser File и путь, возвращаемый через getFiles(), оставались согласованными. */ export function rebaseTree(root, prefix) { root.path = `${prefix}/${root.path}`; if (root.file) root.file = new File([root.file], root.path, { lastModified: root.file.lastModified }); root.children.forEach((child) => rebaseTree(child, prefix)); return root; }