import path from "node:path";
function isNodeError(value) {
    return Boolean(value && typeof value === "object" && "code" in value);
}
export function isNotFoundPathError(value) {
    return isNodeError(value) && (value.code === "ENOENT" || value.code === "ENOTDIR");
}
export function isSymlinkOpenError(value) {
    return (isNodeError(value) &&
        (value.code === "ELOOP" || value.code === "EINVAL" || value.code === "ENOTSUP"));
}
export function isPathInside(root, target) {
    const relative = path.relative(root, target);
    if (!relative || relative === "") {
        return true;
    }
    return !(relative.startsWith("..") || path.isAbsolute(relative));
}
