Skip to content

Commit

Permalink
Use constants for core >=0.16, also updated core dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Jul 25, 2024
1 parent f8a30e6 commit 54d10d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@zenfs/core": "^0.12.10"
"@zenfs/core": ">=0.12.10"
},
"keywords": [
"filesystem",
Expand Down
9 changes: 5 additions & 4 deletions src/access.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Backend, FileSystemMetadata } from '@zenfs/core';
import { ErrnoError, Async, Errno, FileSystem, FileType, InMemory, PreloadFile, Stats } from '@zenfs/core';
import { Async, Errno, ErrnoError, FileSystem, InMemory, PreloadFile, Stats } from '@zenfs/core';
import { S_IFDIR, S_IFREG } from '@zenfs/core/emulation/constants.js';
import { basename, dirname, join } from '@zenfs/core/emulation/path.js';
import { convertException, type ConvertException } from './utils.js';

Expand Down Expand Up @@ -106,11 +107,11 @@ export class WebAccessFS extends Async(FileSystem) {
throw ErrnoError.With('ENOENT', path, 'stat');
}
if (handle instanceof FileSystemDirectoryHandle) {
return new Stats({ mode: 0o777 | FileType.DIRECTORY, size: 4096 });
return new Stats({ mode: 0o777 | S_IFDIR, size: 4096 });
}
if (handle instanceof FileSystemFileHandle) {
const { lastModified, size } = await handle.getFile();
return new Stats({ mode: 0o777 | FileType.FILE, size, mtimeMs: lastModified });
return new Stats({ mode: 0o777 | S_IFREG, size, mtimeMs: lastModified });
}
throw new ErrnoError(Errno.EBADE, 'Handle is not a directory or file', path, 'stat');
}
Expand All @@ -123,7 +124,7 @@ export class WebAccessFS extends Async(FileSystem) {
try {
const file = await handle.getFile();
const data = new Uint8Array(await file.arrayBuffer());
const stats = new Stats({ mode: 0o777 | FileType.FILE, size: file.size, mtimeMs: file.lastModified });
const stats = new Stats({ mode: 0o777 | S_IFREG, size: file.size, mtimeMs: file.lastModified });
return new PreloadFile(this, path, flag, stats, data);
} catch (ex) {
throw convertException(ex as ConvertException, path, 'openFile');
Expand Down

0 comments on commit 54d10d4

Please sign in to comment.