2025-09-20 23:23:28 +00:00
|
|
|
import type { Id } from "../_generated/dataModel"
|
|
|
|
|
|
|
|
export type DirectoryPathComponent = {
|
2025-09-20 23:54:27 +00:00
|
|
|
handle: DirectoryHandle
|
2025-09-20 23:23:28 +00:00
|
|
|
name: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export type FilePathComponent = {
|
2025-09-20 23:54:27 +00:00
|
|
|
handle: FileHandle
|
2025-09-20 23:23:28 +00:00
|
|
|
name: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export type PathComponent = FilePathComponent | DirectoryPathComponent
|
|
|
|
|
|
|
|
export type FilePath = [...DirectoryPathComponent[], PathComponent]
|
|
|
|
|
|
|
|
export type ReverseFilePath = [PathComponent, ...DirectoryPathComponent[]]
|
2025-09-20 23:54:27 +00:00
|
|
|
|
|
|
|
export type FileHandle = {
|
|
|
|
kind: "file"
|
|
|
|
id: Id<"files">
|
|
|
|
}
|
|
|
|
|
|
|
|
export type DirectoryHandle = {
|
|
|
|
kind: "directory"
|
|
|
|
id: Id<"directories">
|
|
|
|
}
|
|
|
|
|
|
|
|
export type FileSystemHandle = DirectoryHandle | FileHandle
|
|
|
|
|
|
|
|
export function newDirectoryHandle(id: Id<"directories">): DirectoryHandle {
|
|
|
|
return { kind: "directory", id }
|
|
|
|
}
|
|
|
|
|
|
|
|
export function newFileHandle(id: Id<"files">): FileHandle {
|
|
|
|
return { kind: "file", id }
|
|
|
|
}
|