summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-09-05 20:37:28 +1000
committerGitHub <noreply@github.com>2024-09-05 20:37:28 +1000
commitc73b4a0877ca134a05262dc15524f54ff471cc3a (patch)
tree25522be4b43ee2209ee924099f6f26bf3c053dad /ext
parentb01578ae1fc1da65ac38daec31a23c9ef652aa74 (diff)
BREAKING(fs): remove `Deno.seek[Sync]()` (#25449)
Towards #22079
Diffstat (limited to 'ext')
-rw-r--r--ext/fs/30_fs.js22
-rw-r--r--ext/node/polyfills/_fs/_fs_read.ts18
-rw-r--r--ext/node/polyfills/_fs/_fs_readv.ts6
-rw-r--r--ext/node/polyfills/_fs/_fs_write.mjs6
-rw-r--r--ext/node/polyfills/_fs/_fs_writev.mjs6
-rw-r--r--ext/node/polyfills/internal_binding/node_file.ts4
6 files changed, 24 insertions, 38 deletions
diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js
index f979badb9..3509a61d7 100644
--- a/ext/fs/30_fs.js
+++ b/ext/fs/30_fs.js
@@ -543,22 +543,6 @@ async function funlock(rid) {
await op_fs_funlock_async_unstable(rid);
}
-function seekSync(
- rid,
- offset,
- whence,
-) {
- return op_fs_seek_sync(rid, offset, whence);
-}
-
-function seek(
- rid,
- offset,
- whence,
-) {
- return op_fs_seek_async(rid, offset, whence);
-}
-
function openSync(
path,
options,
@@ -663,11 +647,11 @@ class FsFile {
}
seek(offset, whence) {
- return seek(this.#rid, offset, whence);
+ return op_fs_seek_async(this.#rid, offset, whence);
}
seekSync(offset, whence) {
- return seekSync(this.#rid, offset, whence);
+ return op_fs_seek_sync(this.#rid, offset, whence);
}
async stat() {
@@ -979,8 +963,6 @@ export {
removeSync,
rename,
renameSync,
- seek,
- seekSync,
stat,
statSync,
symlink,
diff --git a/ext/node/polyfills/_fs/_fs_read.ts b/ext/node/polyfills/_fs/_fs_read.ts
index 90255195f..dec3a8bbd 100644
--- a/ext/node/polyfills/_fs/_fs_read.ts
+++ b/ext/node/polyfills/_fs/_fs_read.ts
@@ -6,7 +6,6 @@
import { Buffer } from "node:buffer";
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
import * as io from "ext:deno_io/12_io.js";
-import * as fs from "ext:deno_fs/30_fs.js";
import { ReadOptions } from "ext:deno_node/_fs/_fs_common.ts";
import {
arrayBufferViewToUint8Array,
@@ -18,6 +17,7 @@ import {
validateInteger,
} from "ext:deno_node/internal/validators.mjs";
import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts";
+import { op_fs_seek_async, op_fs_seek_sync } from "ext:core/ops";
type readSyncOptions = {
offset: number;
@@ -119,15 +119,19 @@ export function read(
try {
let nread: number | null;
if (typeof position === "number" && position >= 0) {
- const currentPosition = await fs.seek(fd, 0, io.SeekMode.Current);
+ const currentPosition = await op_fs_seek_async(
+ fd,
+ 0,
+ io.SeekMode.Current,
+ );
// We use sync calls below to avoid being affected by others during
// these calls.
- fs.seekSync(fd, position, io.SeekMode.Start);
+ op_fs_seek_sync(fd, position, io.SeekMode.Start);
nread = io.readSync(
fd,
arrayBufferViewToUint8Array(buffer).subarray(offset, offset + length),
);
- fs.seekSync(fd, currentPosition, io.SeekMode.Start);
+ op_fs_seek_sync(fd, currentPosition, io.SeekMode.Start);
} else {
nread = await io.read(
fd,
@@ -191,8 +195,8 @@ export function readSync(
let currentPosition = 0;
if (typeof position === "number" && position >= 0) {
- currentPosition = fs.seekSync(fd, 0, io.SeekMode.Current);
- fs.seekSync(fd, position, io.SeekMode.Start);
+ currentPosition = op_fs_seek_sync(fd, 0, io.SeekMode.Current);
+ op_fs_seek_sync(fd, position, io.SeekMode.Start);
}
const numberOfBytesRead = io.readSync(
@@ -201,7 +205,7 @@ export function readSync(
);
if (typeof position === "number" && position >= 0) {
- fs.seekSync(fd, currentPosition, io.SeekMode.Start);
+ op_fs_seek_sync(fd, currentPosition, io.SeekMode.Start);
}
return numberOfBytesRead ?? 0;
diff --git a/ext/node/polyfills/_fs/_fs_readv.ts b/ext/node/polyfills/_fs/_fs_readv.ts
index 7d87c51f7..384f5e319 100644
--- a/ext/node/polyfills/_fs/_fs_readv.ts
+++ b/ext/node/polyfills/_fs/_fs_readv.ts
@@ -14,7 +14,7 @@ import {
import { maybeCallback } from "ext:deno_node/_fs/_fs_common.ts";
import { validateInteger } from "ext:deno_node/internal/validators.mjs";
import * as io from "ext:deno_io/12_io.js";
-import * as fs from "ext:deno_fs/30_fs.js";
+import { op_fs_seek_async, op_fs_seek_sync } from "ext:core/ops";
type Callback = (
err: ErrnoException | null,
@@ -56,7 +56,7 @@ export function readv(
position: number | null,
) => {
if (typeof position === "number") {
- await fs.seek(fd, position, io.SeekMode.Start);
+ await op_fs_seek_async(fd, position, io.SeekMode.Start);
}
let readTotal = 0;
@@ -104,7 +104,7 @@ export function readvSync(
}
if (typeof position === "number") {
validateInteger(position, "position", 0);
- fs.seekSync(fd, position, io.SeekMode.Start);
+ op_fs_seek_sync(fd, position, io.SeekMode.Start);
}
let readTotal = 0;
diff --git a/ext/node/polyfills/_fs/_fs_write.mjs b/ext/node/polyfills/_fs/_fs_write.mjs
index b4b133222..254094c9a 100644
--- a/ext/node/polyfills/_fs/_fs_write.mjs
+++ b/ext/node/polyfills/_fs/_fs_write.mjs
@@ -10,7 +10,6 @@ import {
validateInteger,
} from "ext:deno_node/internal/validators.mjs";
import * as io from "ext:deno_io/12_io.js";
-import * as fs from "ext:deno_fs/30_fs.js";
import {
arrayBufferViewToUint8Array,
getValidatedFd,
@@ -19,6 +18,7 @@ import {
} from "ext:deno_node/internal/fs/utils.mjs";
import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts";
import { maybeCallback } from "ext:deno_node/_fs/_fs_common.ts";
+import { op_fs_seek_async, op_fs_seek_sync } from "ext:core/ops";
export function writeSync(fd, buffer, offset, length, position) {
fd = getValidatedFd(fd);
@@ -26,7 +26,7 @@ export function writeSync(fd, buffer, offset, length, position) {
const innerWriteSync = (fd, buffer, offset, length, position) => {
buffer = arrayBufferViewToUint8Array(buffer);
if (typeof position === "number") {
- fs.seekSync(fd, position, io.SeekMode.Start);
+ op_fs_seek_sync(fd, position, io.SeekMode.Start);
}
let currentOffset = offset;
const end = offset + length;
@@ -70,7 +70,7 @@ export function write(fd, buffer, offset, length, position, callback) {
const innerWrite = async (fd, buffer, offset, length, position) => {
buffer = arrayBufferViewToUint8Array(buffer);
if (typeof position === "number") {
- await fs.seek(fd, position, io.SeekMode.Start);
+ await op_fs_seek_async(fd, position, io.SeekMode.Start);
}
let currentOffset = offset;
const end = offset + length;
diff --git a/ext/node/polyfills/_fs/_fs_writev.mjs b/ext/node/polyfills/_fs/_fs_writev.mjs
index 2f65c570e..055bce0b2 100644
--- a/ext/node/polyfills/_fs/_fs_writev.mjs
+++ b/ext/node/polyfills/_fs/_fs_writev.mjs
@@ -9,7 +9,7 @@ import { validateBufferArray } from "ext:deno_node/internal/fs/utils.mjs";
import { getValidatedFd } from "ext:deno_node/internal/fs/utils.mjs";
import { maybeCallback } from "ext:deno_node/_fs/_fs_common.ts";
import * as io from "ext:deno_io/12_io.js";
-import * as fs from "ext:deno_fs/30_fs.js";
+import { op_fs_seek_async, op_fs_seek_sync } from "ext:core/ops";
export function writev(fd, buffers, position, callback) {
const innerWritev = async (fd, buffers, position) => {
@@ -23,7 +23,7 @@ export function writev(fd, buffers, position, callback) {
}
}
if (typeof position === "number") {
- await fs.seekSync(fd, position, io.SeekMode.Start);
+ await op_fs_seek_async(fd, position, io.SeekMode.Start);
}
const buffer = Buffer.concat(chunks);
let currentOffset = 0;
@@ -64,7 +64,7 @@ export function writevSync(fd, buffers, position) {
}
}
if (typeof position === "number") {
- fs.seekSync(fd, position, io.SeekMode.Start);
+ op_fs_seek_sync(fd, position, io.SeekMode.Start);
}
const buffer = Buffer.concat(chunks);
let currentOffset = 0;
diff --git a/ext/node/polyfills/internal_binding/node_file.ts b/ext/node/polyfills/internal_binding/node_file.ts
index c7b0bb7e6..6c134ec4b 100644
--- a/ext/node/polyfills/internal_binding/node_file.ts
+++ b/ext/node/polyfills/internal_binding/node_file.ts
@@ -30,7 +30,7 @@
import { assert } from "ext:deno_node/_util/asserts.ts";
import * as io from "ext:deno_io/12_io.js";
-import * as fs from "ext:deno_fs/30_fs.js";
+import { op_fs_seek_sync } from "ext:core/ops";
/**
* Write to the given file from the given buffer synchronously.
@@ -63,7 +63,7 @@ export function writeBuffer(
);
if (position) {
- fs.seekSync(fd, position, io.SeekMode.Current);
+ op_fs_seek_sync(fd, position, io.SeekMode.Current);
}
const subarray = buffer.subarray(offset, offset + length);