/* * Copyright (C) 2022 Klaus Reimer * See LICENSE.md for licensing information. */ import { constants } from "node:fs"; import { access, stat } from "node:fs/promises"; /** * Checks if given path is readable. * * @param path - The path to check. * @returns True if path is readable, false if not. */ export async function isPathReadable(path: string): Promise { try { await access(path, constants.R_OK); return true; } catch { return false; } } /** * Checks if given path is a directory. * * @param path - The path to check. * @returns True if path is a directory, false if not. */ export async function isDirectory(path: string): Promise { return (await stat(path)).isDirectory(); }