This commit is contained in:
@@ -3,6 +3,14 @@ import * as asyncfs from 'node:fs/promises';
|
||||
import * as path from 'node:path';
|
||||
import NodeFileSystemHandle from './NodeFileSystemHandle.ts';
|
||||
import NodeFileSystemFileHandle from './NodeFileSystemFileHandle.ts';
|
||||
import type {
|
||||
FileSystemDirectoryHandle,
|
||||
FileSystemGetDirectoryOptions,
|
||||
FileSystemDirectoryHandleAsyncIterator,
|
||||
FileSystemGetFileOptions,
|
||||
FileSystemRemoveOptions,
|
||||
FileSystemHandle
|
||||
} from '@sugoidogo/importable-types-web'
|
||||
|
||||
export default class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle implements FileSystemDirectoryHandle {
|
||||
declare kind: "directory";
|
||||
|
||||
@@ -4,6 +4,13 @@ import * as path from 'node:path';
|
||||
import NodeFileSystemHandle from './NodeFileSystemHandle.ts';
|
||||
import NodeFileSystemWritableFileStream from './NodeFileSystemWriteableFileStream.ts';
|
||||
import mime from 'mime'
|
||||
import type {
|
||||
FileSystemFileHandle,
|
||||
FileSystemGetFileOptions,
|
||||
FileSystemCreateWritableOptions,
|
||||
FileSystemWritableFileStream,
|
||||
File
|
||||
} from '@sugoidogo/importable-types-web'
|
||||
|
||||
export default class NodeFileSystemFileHandle extends NodeFileSystemHandle implements FileSystemFileHandle {
|
||||
declare kind: "file";
|
||||
@@ -20,10 +27,10 @@ export default class NodeFileSystemFileHandle extends NodeFileSystemHandle imple
|
||||
async getFile(): Promise<File> {
|
||||
const stats = await asyncfs.stat(this.path)
|
||||
const type = mime.getType(this.name.split('.').pop())
|
||||
return asyncfs.readFile(this.path).then(buffer => Object.assign(new Blob([buffer],{type}), {
|
||||
return asyncfs.readFile(this.path).then(buffer => Object.assign(new Blob([buffer], { type }), {
|
||||
lastModified: stats.mtimeMs,
|
||||
name: this.path,
|
||||
webkitRelativePath: this.path
|
||||
}))
|
||||
})) as unknown as File // TODO ArrayBufferView and DataView are incompatible types
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
import * as path from 'node:path'
|
||||
import type {
|
||||
FileSystemHandle,
|
||||
FileSystemHandleKind
|
||||
} from '@sugoidogo/importable-types-web'
|
||||
|
||||
export default class NodeFileSystemHandle implements FileSystemHandle {
|
||||
kind: FileSystemHandleKind;
|
||||
|
||||
@@ -2,6 +2,12 @@ import * as fs from 'node:fs'
|
||||
import * as asyncfs from 'node:fs/promises'
|
||||
import * as path from 'node:path'
|
||||
import { Writable } from 'node:stream'
|
||||
import type {
|
||||
FileSystemWritableFileStream,
|
||||
FileSystemCreateWritableOptions,
|
||||
FileSystemWriteChunkType,
|
||||
WriteParams
|
||||
} from '@sugoidogo/importable-types-web'
|
||||
|
||||
export default class NodeFileSystemWritableFileStream extends WritableStream implements FileSystemWritableFileStream {
|
||||
#seek_position = 0
|
||||
|
||||
Reference in New Issue
Block a user