import * as path from "node:path"; /** * 规范化会话文件路径, 用于跨平台比较会话 owner. * * @param value 会话文件路径 * @returns 规范化后的绝对路径, 空值时返回 undefined */ export function normalizeSessionFile(value: string | undefined): string | undefined { if (!value || !value.trim()) return undefined; const normalized = path.normalize(path.resolve(value)); return process.platform === "win32" ? normalized.toLowerCase() : normalized; } /** * 判断 Schedule 是否属于指定会话. * * @param ownerSessionFile Schedule 中保存的 owner 会话文件 * @param currentSessionFile 当前会话文件 * @returns owner 是否匹配当前会话 */ export function isCurrentSessionOwner(ownerSessionFile: string | undefined, currentSessionFile: string | undefined): boolean { const owner = normalizeSessionFile(ownerSessionFile); const current = normalizeSessionFile(currentSessionFile); return owner !== undefined && current !== undefined && owner === current; }