Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Updated to latest core
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Apr 2, 2024
1 parent ee9f5d0 commit 04b1b2d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@zenfs/core": "^0.3.2"
"@zenfs/core": "^0.5.0"
}
}
28 changes: 17 additions & 11 deletions src/IsoFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Backend } from '@zenfs/core/backends/backend.js';
import type { Cred } from '@zenfs/core/cred.js';
import * as path from '@zenfs/core/emulation/path.js';
import { resolve } from '@zenfs/core/emulation/path.js';
import { FileFlag, NoSyncFile } from '@zenfs/core/file.js';
import { NoSyncFile, isWriteable } from '@zenfs/core/file.js';
import { FileSystem, Readonly, Sync, type FileSystemMetadata } from '@zenfs/core/filesystem.js';
import { FileType, Stats } from '@zenfs/core/stats.js';
import { DirectoryRecord } from './DirectoryRecord.js';
Expand Down Expand Up @@ -98,8 +98,8 @@ export class IsoFS extends Readonly(Sync(FileSystem)) {
return this._getStats(p, record)!;
}

public openFileSync(path: string, flag: FileFlag, cred: Cred): NoSyncFile<this> {
if (flag.isWriteable()) {
public openFileSync(path: string, flag: string, cred: Cred): NoSyncFile<this> {
if (isWriteable(flag)) {
// Cannot write to RO file systems.
throw new ApiError(ErrorCode.EPERM, path);
}
Expand Down Expand Up @@ -162,10 +162,10 @@ export class IsoFS extends Readonly(Sync(FileSystem)) {
}

let mode = 0o555;
const date = record.recordingDate.getTime();
let atime = date,
mtime = date,
ctime = date;
const time = record.recordingDate.getTime();
let atimeMs = time,
mtimeMs = time,
ctimeMs = time;
if (record.hasRockRidge) {
const entries = record.getSUEntries(this._data);
for (const entry of entries) {
Expand All @@ -179,19 +179,25 @@ export class IsoFS extends Readonly(Sync(FileSystem)) {
}
const flags = entry.flags();
if (flags & TFFlags.ACCESS) {
atime = entry.access()!.getTime();
atimeMs = entry.access()!.getTime();
}
if (flags & TFFlags.MODIFY) {
mtime = entry.modify()!.getTime();
mtimeMs = entry.modify()!.getTime();
}
if (flags & TFFlags.CREATION) {
ctime = entry.creation()!.getTime();
ctimeMs = entry.creation()!.getTime();
}
}
}
// Mask out writeable flags. This is a RO file system.
mode &= 0o555;
return new Stats(record.isDirectory(this._data) ? FileType.DIRECTORY : FileType.FILE, record.dataLength, mode, atime, mtime, ctime);
return new Stats({
mode: mode | (record.isDirectory(this._data) ? FileType.DIRECTORY : FileType.FILE),
size: record.dataLength,
atimeMs,
mtimeMs,
ctimeMs,
});
}
}

Expand Down

0 comments on commit 04b1b2d

Please sign in to comment.