summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_fs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/_fs')
-rw-r--r--ext/node/polyfills/_fs/_fs_exists.ts6
-rw-r--r--ext/node/polyfills/_fs/_fs_link.ts10
-rw-r--r--ext/node/polyfills/_fs/_fs_readFile.ts6
-rw-r--r--ext/node/polyfills/_fs/_fs_readlink.ts6
-rw-r--r--ext/node/polyfills/_fs/_fs_rename.ts10
-rw-r--r--ext/node/polyfills/_fs/_fs_symlink.ts10
-rw-r--r--ext/node/polyfills/_fs/_fs_truncate.ts6
-rw-r--r--ext/node/polyfills/_fs/_fs_utimes.ts6
-rw-r--r--ext/node/polyfills/_fs/_fs_writeFile.ts6
9 files changed, 33 insertions, 33 deletions
diff --git a/ext/node/polyfills/_fs/_fs_exists.ts b/ext/node/polyfills/_fs/_fs_exists.ts
index 37ce599e9..32eb7948a 100644
--- a/ext/node/polyfills/_fs/_fs_exists.ts
+++ b/ext/node/polyfills/_fs/_fs_exists.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
type ExistsCallback = (exists: boolean) => void;
@@ -9,7 +9,7 @@ type ExistsCallback = (exists: boolean) => void;
* Deprecated in node api
*/
export function exists(path: string | URL, callback: ExistsCallback) {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
Deno.lstat(path).then(() => callback(true), () => callback(false));
}
@@ -30,7 +30,7 @@ Object.defineProperty(exists, kCustomPromisifiedSymbol, {
* are implemented. See https://github.com/denoland/deno/issues/3403
*/
export function existsSync(path: string | URL): boolean {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
try {
Deno.lstatSync(path);
return true;
diff --git a/ext/node/polyfills/_fs/_fs_link.ts b/ext/node/polyfills/_fs/_fs_link.ts
index 3039ade09..affa42852 100644
--- a/ext/node/polyfills/_fs/_fs_link.ts
+++ b/ext/node/polyfills/_fs/_fs_link.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import { promisify } from "ext:deno_node/internal/util.mjs";
/**
@@ -13,9 +13,9 @@ export function link(
callback: CallbackWithError,
) {
existingPath = existingPath instanceof URL
- ? fromFileUrl(existingPath)
+ ? pathFromURL(existingPath)
: existingPath;
- newPath = newPath instanceof URL ? fromFileUrl(newPath) : newPath;
+ newPath = newPath instanceof URL ? pathFromURL(newPath) : newPath;
Deno.link(existingPath, newPath).then(() => callback(null), callback);
}
@@ -38,9 +38,9 @@ export function linkSync(
newPath: string | URL,
) {
existingPath = existingPath instanceof URL
- ? fromFileUrl(existingPath)
+ ? pathFromURL(existingPath)
: existingPath;
- newPath = newPath instanceof URL ? fromFileUrl(newPath) : newPath;
+ newPath = newPath instanceof URL ? pathFromURL(newPath) : newPath;
Deno.linkSync(existingPath, newPath);
}
diff --git a/ext/node/polyfills/_fs/_fs_readFile.ts b/ext/node/polyfills/_fs/_fs_readFile.ts
index b3bd5b94c..04e42e391 100644
--- a/ext/node/polyfills/_fs/_fs_readFile.ts
+++ b/ext/node/polyfills/_fs/_fs_readFile.ts
@@ -8,7 +8,7 @@ import {
import { Buffer } from "ext:deno_node/buffer.ts";
import { readAll } from "ext:deno_io/12_io.js";
import { FileHandle } from "ext:deno_node/internal/fs/handle.ts";
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import {
BinaryEncodings,
Encodings,
@@ -57,7 +57,7 @@ export function readFile(
optOrCallback?: FileOptionsArgument | Callback | null | undefined,
callback?: Callback,
) {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
let cb: Callback | undefined;
if (typeof optOrCallback === "function") {
cb = optOrCallback;
@@ -105,7 +105,7 @@ export function readFileSync(
path: string | URL,
opt?: FileOptionsArgument,
): string | Buffer {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
const data = Deno.readFileSync(path);
const encoding = getEncoding(opt);
if (encoding && encoding !== "binary") {
diff --git a/ext/node/polyfills/_fs/_fs_readlink.ts b/ext/node/polyfills/_fs/_fs_readlink.ts
index 982376152..c5e344c4b 100644
--- a/ext/node/polyfills/_fs/_fs_readlink.ts
+++ b/ext/node/polyfills/_fs/_fs_readlink.ts
@@ -6,7 +6,7 @@ import {
MaybeEmpty,
notImplemented,
} from "ext:deno_node/_utils.ts";
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import { promisify } from "ext:deno_node/internal/util.mjs";
type ReadlinkCallback = (
@@ -55,7 +55,7 @@ export function readlink(
optOrCallback: ReadlinkCallback | ReadlinkOptions,
callback?: ReadlinkCallback,
) {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
let cb: ReadlinkCallback | undefined;
if (typeof optOrCallback === "function") {
@@ -83,7 +83,7 @@ export function readlinkSync(
path: string | URL,
opt?: ReadlinkOptions,
): string | Uint8Array {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
return maybeEncode(Deno.readLinkSync(path), getEncoding(opt));
}
diff --git a/ext/node/polyfills/_fs/_fs_rename.ts b/ext/node/polyfills/_fs/_fs_rename.ts
index 5d87619c7..ff0a7246b 100644
--- a/ext/node/polyfills/_fs/_fs_rename.ts
+++ b/ext/node/polyfills/_fs/_fs_rename.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import { promisify } from "ext:deno_node/internal/util.mjs";
export function rename(
@@ -7,8 +7,8 @@ export function rename(
newPath: string | URL,
callback: (err?: Error) => void,
) {
- oldPath = oldPath instanceof URL ? fromFileUrl(oldPath) : oldPath;
- newPath = newPath instanceof URL ? fromFileUrl(newPath) : newPath;
+ oldPath = oldPath instanceof URL ? pathFromURL(oldPath) : oldPath;
+ newPath = newPath instanceof URL ? pathFromURL(newPath) : newPath;
if (!callback) throw new Error("No callback function supplied");
@@ -21,8 +21,8 @@ export const renamePromise = promisify(rename) as (
) => Promise<void>;
export function renameSync(oldPath: string | URL, newPath: string | URL) {
- oldPath = oldPath instanceof URL ? fromFileUrl(oldPath) : oldPath;
- newPath = newPath instanceof URL ? fromFileUrl(newPath) : newPath;
+ oldPath = oldPath instanceof URL ? pathFromURL(oldPath) : oldPath;
+ newPath = newPath instanceof URL ? pathFromURL(newPath) : newPath;
Deno.renameSync(oldPath, newPath);
}
diff --git a/ext/node/polyfills/_fs/_fs_symlink.ts b/ext/node/polyfills/_fs/_fs_symlink.ts
index 23e4deaa5..48da49dd1 100644
--- a/ext/node/polyfills/_fs/_fs_symlink.ts
+++ b/ext/node/polyfills/_fs/_fs_symlink.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import { promisify } from "ext:deno_node/internal/util.mjs";
type SymlinkType = "file" | "dir";
@@ -11,8 +11,8 @@ export function symlink(
typeOrCallback: SymlinkType | CallbackWithError,
maybeCallback?: CallbackWithError,
) {
- target = target instanceof URL ? fromFileUrl(target) : target;
- path = path instanceof URL ? fromFileUrl(path) : path;
+ target = target instanceof URL ? pathFromURL(target) : target;
+ path = path instanceof URL ? pathFromURL(path) : path;
const type: SymlinkType = typeof typeOrCallback === "string"
? typeOrCallback
@@ -38,8 +38,8 @@ export function symlinkSync(
path: string | URL,
type?: SymlinkType,
) {
- target = target instanceof URL ? fromFileUrl(target) : target;
- path = path instanceof URL ? fromFileUrl(path) : path;
+ target = target instanceof URL ? pathFromURL(target) : target;
+ path = path instanceof URL ? pathFromURL(path) : path;
type = type || "file";
Deno.symlinkSync(target, path, { type });
diff --git a/ext/node/polyfills/_fs/_fs_truncate.ts b/ext/node/polyfills/_fs/_fs_truncate.ts
index b6d39352b..596c11211 100644
--- a/ext/node/polyfills/_fs/_fs_truncate.ts
+++ b/ext/node/polyfills/_fs/_fs_truncate.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import { promisify } from "ext:deno_node/internal/util.mjs";
export function truncate(
@@ -8,7 +8,7 @@ export function truncate(
lenOrCallback: number | CallbackWithError,
maybeCallback?: CallbackWithError,
) {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
const len: number | undefined = typeof lenOrCallback === "number"
? lenOrCallback
: undefined;
@@ -27,7 +27,7 @@ export const truncatePromise = promisify(truncate) as (
) => Promise<void>;
export function truncateSync(path: string | URL, len?: number) {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
Deno.truncateSync(path, len);
}
diff --git a/ext/node/polyfills/_fs/_fs_utimes.ts b/ext/node/polyfills/_fs/_fs_utimes.ts
index 93b108f00..0fef8fd05 100644
--- a/ext/node/polyfills/_fs/_fs_utimes.ts
+++ b/ext/node/polyfills/_fs/_fs_utimes.ts
@@ -1,7 +1,7 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import { promisify } from "ext:deno_node/internal/util.mjs";
function getValidTime(
@@ -30,7 +30,7 @@ export function utimes(
mtime: number | string | Date,
callback: CallbackWithError,
) {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
if (!callback) {
throw new Deno.errors.InvalidData("No callback function supplied");
@@ -53,7 +53,7 @@ export function utimesSync(
atime: number | string | Date,
mtime: number | string | Date,
) {
- path = path instanceof URL ? fromFileUrl(path) : path;
+ path = path instanceof URL ? pathFromURL(path) : path;
atime = getValidTime(atime, "atime");
mtime = getValidTime(mtime, "mtime");
diff --git a/ext/node/polyfills/_fs/_fs_writeFile.ts b/ext/node/polyfills/_fs/_fs_writeFile.ts
index a72d49147..fd573147b 100644
--- a/ext/node/polyfills/_fs/_fs_writeFile.ts
+++ b/ext/node/polyfills/_fs/_fs_writeFile.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { Encodings } from "ext:deno_node/_utils.ts";
-import { fromFileUrl } from "ext:deno_node/path.ts";
+import { pathFromURL } from "ext:deno_web/00_infra.js";
import { Buffer } from "ext:deno_node/buffer.ts";
import {
CallbackWithError,
@@ -41,7 +41,7 @@ export function writeFile(
throw new TypeError("Callback must be a function.");
}
- pathOrRid = pathOrRid instanceof URL ? fromFileUrl(pathOrRid) : pathOrRid;
+ pathOrRid = pathOrRid instanceof URL ? pathFromURL(pathOrRid) : pathOrRid;
const flag: string | undefined = isFileOptions(options)
? options.flag
@@ -107,7 +107,7 @@ export function writeFileSync(
data: string | Uint8Array | Object,
options?: Encodings | WriteFileOptions,
) {
- pathOrRid = pathOrRid instanceof URL ? fromFileUrl(pathOrRid) : pathOrRid;
+ pathOrRid = pathOrRid instanceof URL ? pathFromURL(pathOrRid) : pathOrRid;
const flag: string | undefined = isFileOptions(options)
? options.flag