Files
node-file-system-adapter/src/NodeFileSystemHandle.ts
T
sugoidogo 8bc2c7d70c
Release / release (push) Successful in 24s
refactor
2026-02-16 15:57:22 -08:00

22 lines
835 B
TypeScript

import * as Path from 'node:path'
import type {
FileSystemHandle,
FileSystemHandleKind
} from '@sugoidogo/importable-types-web'
import type NodeFileSystemDirectoryHandle from './NodeFileSystemDirectoryHandle';
export default class NodeFileSystemHandle implements FileSystemHandle {
kind: FileSystemHandleKind;
path: string;
origin: NodeFileSystemDirectoryHandle
get name() { return Path.basename(this.path) }
constructor(path: string, options: { origin?: NodeFileSystemDirectoryHandle } = {}) {
if (!Path.isAbsolute(path)) path = Path.resolve(path)
this.path = path
this.origin = options.origin
}
async isSameEntry(other: FileSystemHandle): Promise<boolean> {
if (!(other instanceof NodeFileSystemHandle)) return false
return this.path === other.path
}
}