22 lines
835 B
TypeScript
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
|
|
}
|
|
} |