import { Vault } from "obsidian"; export async function mkdirp(vault: Vault, folderPath: string): Promise { // Noop if the path exists if (vault.getAbstractFileByPath(folderPath)) { return; } // Start building the path incrementally const pathParts = folderPath.split("/"); let currentPath = ""; for (const part of pathParts) { currentPath = currentPath ? `${currentPath}/${part}` : part; try { // Check if folder exists if (!vault.getAbstractFileByPath(currentPath)) { // Create the folder if it doesn't exist await vault.createFolder(currentPath); } } catch (error) { console.error(`Error creating folder ${currentPath}:`, error); throw error; } } }