Skip to content

Commit

Permalink
fix: work on fs impl
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Nov 20, 2024
1 parent fb0b1c7 commit a00b4da
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/platform-deno/src/DenoFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ const makeFile = (() => {
}

get stat(): Effect.Effect<FileSystem.File.Info, PlatformError> {
// FIXME: `makeFileInfo` takes a Deno.FileInfo.
return Effect.map(fstat(this.fd), makeNodeFileInfo);
}

Expand All @@ -340,6 +339,7 @@ const makeFile = (() => {
this.position += offsetSize;
}

// Used in tests.
return this.position;
}),
);
Expand Down Expand Up @@ -376,7 +376,7 @@ const makeFile = (() => {
buffer,
position: this.position,
}),
(bytesRead: number): Option.Option<Uint8Array> => {
(bytesRead): Option.Option<Uint8Array> => {
if (bytesRead === 0) {
return Option.none();
}
Expand All @@ -386,8 +386,8 @@ const makeFile = (() => {
return Option.some(buffer);
}

const dst = new Uint8Array(bytesRead);
new Uint8Array(dst).set(new Uint8Array(buffer, 0, bytesRead));
const dst = buffer.slice(0, bytesRead);

return Option.some(dst);
},
),
Expand All @@ -402,7 +402,10 @@ const makeFile = (() => {
Effect.map(
// FIXME: `truncate` takes a path, not a FileDescriptor.
// TODO: PR `@effect/platform`, b/c passing a `FileDescriptor` to truncate is also deprecated in Node.js.
ftruncateFactory("")(this.fd, length ? Number(length) : undefined),
ftruncateFactory("truncate")(
this.fd,
length ? Number(length) : undefined,
),
() => {
if (!this.append) {
const len = BigInt(length ?? 0);
Expand Down

0 comments on commit a00b4da

Please sign in to comment.