Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ext/node/polyfills/01_require.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ let hasInspectBrk = false;
let usesLocalNodeModulesDir = false;

function stat(filename) {
// TODO: required only on windows
// filename = path.toNamespacedPath(filename);
if (statCache !== null) {
const result = statCache.get(filename);
if (result !== undefined) {
Expand Down
5 changes: 2 additions & 3 deletions ext/node/polyfills/_fs/_fs_chmod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
import { getValidatedPathToString } from "ext:deno_node/internal/fs/utils.mjs";
import * as pathModule from "node:path";
import { parseFileMode } from "ext:deno_node/internal/validators.mjs";
import type { Buffer } from "node:buffer";
import { promisify } from "ext:deno_node/internal/util.mjs";
Expand All @@ -20,7 +19,7 @@ export function chmod(
mode = parseFileMode(mode, "mode");

PromisePrototypeThen(
Deno.chmod(pathModule.toNamespacedPath(path), mode),
Deno.chmod(path, mode),
() => callback(null),
(err: Error) =>
callback(denoErrorToNodeError(err, { syscall: "chmod", path })),
Expand All @@ -37,7 +36,7 @@ export function chmodSync(path: string | Buffer | URL, mode: string | number) {
mode = parseFileMode(mode, "mode");

try {
Deno.chmodSync(pathModule.toNamespacedPath(path), mode);
Deno.chmodSync(path, mode);
} catch (error) {
throw denoErrorToNodeError(error as Error, { syscall: "chmod", path });
}
Expand Down
5 changes: 2 additions & 3 deletions ext/node/polyfills/_fs/_fs_chown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
getValidatedPath,
kMaxUserId,
} from "ext:deno_node/internal/fs/utils.mjs";
import * as pathModule from "node:path";
import { validateInteger } from "ext:deno_node/internal/validators.mjs";
import type { Buffer } from "node:buffer";
import { promisify } from "ext:deno_node/internal/util.mjs";
Expand All @@ -31,7 +30,7 @@ export function chown(
validateInteger(uid, "uid", -1, kMaxUserId);
validateInteger(gid, "gid", -1, kMaxUserId);

Deno.chown(pathModule.toNamespacedPath(path), uid, gid).then(
Deno.chown(path, uid, gid).then(
() => callback(null),
callback,
);
Expand All @@ -56,5 +55,5 @@ export function chownSync(
validateInteger(uid, "uid", -1, kMaxUserId);
validateInteger(gid, "gid", -1, kMaxUserId);

Deno.chownSync(pathModule.toNamespacedPath(path), uid, gid);
Deno.chownSync(path, uid, gid);
}
5 changes: 2 additions & 3 deletions ext/node/polyfills/_fs/_fs_exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getValidatedPathToString } from "ext:deno_node/internal/fs/utils.mjs";
import { primordials } from "ext:core/mod.js";
import { makeCallback } from "ext:deno_node/_fs/_fs_common.ts";
import type { Buffer } from "node:buffer";
import * as pathModule from "node:path";
import { kCustomPromisifiedSymbol } from "ext:deno_node/internal/util.mjs";
import * as process from "node:process";

Expand All @@ -27,7 +26,7 @@ export function exists(path: string | Buffer | URL, callback: ExistsCallback) {
}

PromisePrototypeThen(
op_node_fs_exists(pathModule.toNamespacedPath(path)),
op_node_fs_exists(path),
callback,
);
}
Expand Down Expand Up @@ -63,5 +62,5 @@ export function existsSync(path: string | Buffer | URL): boolean {
}
return false;
}
return op_node_fs_exists_sync(pathModule.toNamespacedPath(path));
return op_node_fs_exists_sync(path);
}
5 changes: 2 additions & 3 deletions ext/node/polyfills/_fs/_fs_lchown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
getValidatedPath,
kMaxUserId,
} from "ext:deno_node/internal/fs/utils.mjs";
import * as pathModule from "node:path";
import { validateInteger } from "ext:deno_node/internal/validators.mjs";
import type { Buffer } from "node:buffer";
import { promisify } from "ext:deno_node/internal/util.mjs";
Expand All @@ -32,7 +31,7 @@ export function lchown(
validateInteger(uid, "uid", -1, kMaxUserId);
validateInteger(gid, "gid", -1, kMaxUserId);

op_node_lchown(pathModule.toNamespacedPath(path), uid, gid).then(
op_node_lchown(path, uid, gid).then(
() => callback(null),
callback,
);
Expand All @@ -57,5 +56,5 @@ export function lchownSync(
validateInteger(uid, "uid", -1, kMaxUserId);
validateInteger(gid, "gid", -1, kMaxUserId);

op_node_lchown_sync(pathModule.toNamespacedPath(path), uid, gid);
op_node_lchown_sync(path, uid, gid);
}
11 changes: 2 additions & 9 deletions ext/node/polyfills/_fs/_fs_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
import { promisify } from "ext:deno_node/internal/util.mjs";
import { primordials } from "ext:core/mod.js";
import { getValidatedPathToString } from "ext:deno_node/internal/fs/utils.mjs";
import * as pathModule from "node:path";

const { PromisePrototypeThen } = primordials;

Expand All @@ -18,10 +17,7 @@ export function link(
newPath = getValidatedPathToString(newPath);

PromisePrototypeThen(
Deno.link(
pathModule.toNamespacedPath(existingPath),
pathModule.toNamespacedPath(newPath),
),
Deno.link(existingPath, newPath),
() => callback(null),
callback,
);
Expand All @@ -39,8 +35,5 @@ export function linkSync(
existingPath = getValidatedPathToString(existingPath);
newPath = getValidatedPathToString(newPath);

Deno.linkSync(
pathModule.toNamespacedPath(existingPath),
pathModule.toNamespacedPath(newPath),
);
Deno.linkSync(existingPath, newPath);
}
5 changes: 2 additions & 3 deletions ext/node/polyfills/_fs/_fs_open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from "ext:deno_node/internal/fs/utils.mjs";
import { FileHandle } from "ext:deno_node/internal/fs/handle.ts";
import type { Buffer } from "node:buffer";
import * as pathModule from "node:path";
import { denoErrorToNodeError } from "ext:deno_node/internal/errors.ts";
import { op_node_open, op_node_open_sync } from "ext:core/ops";

Expand Down Expand Up @@ -69,7 +68,7 @@ export function open(
callback = makeCallback(callback);

PromisePrototypeThen(
op_node_open(pathModule.toNamespacedPath(path), flags, mode),
op_node_open(path, flags, mode),
(rid: number) => callback(null, rid),
(err: Error) =>
callback(denoErrorToNodeError(err, { syscall: "open", path })),
Expand Down Expand Up @@ -110,7 +109,7 @@ export function openSync(
const mode = parseFileMode(maybeMode, "mode", 0o666);

try {
return op_node_open_sync(pathModule.toNamespacedPath(path), flags, mode);
return op_node_open_sync(path, flags, mode);
} catch (err) {
throw denoErrorToNodeError(err as Error, { syscall: "open", path });
}
Expand Down
11 changes: 2 additions & 9 deletions ext/node/polyfills/_fs/_fs_rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getValidatedPathToString } from "ext:deno_node/internal/fs/utils.mjs";
import { validateFunction } from "ext:deno_node/internal/validators.mjs";
import { primordials } from "ext:core/mod.js";
import type { Buffer } from "node:buffer";
import * as pathModule from "node:path";
import { denoErrorToNodeError } from "ext:deno_node/internal/errors.ts";

const {
Expand All @@ -22,10 +21,7 @@ export function rename(
validateFunction(callback, "callback");

PromisePrototypeThen(
Deno.rename(
pathModule.toNamespacedPath(oldPath),
pathModule.toNamespacedPath(newPath),
),
Deno.rename(oldPath, newPath),
() => callback(),
(err: Error) =>
callback(denoErrorToNodeError(err, {
Expand All @@ -49,10 +45,7 @@ export function renameSync(
newPath = getValidatedPathToString(newPath, "newPath");

try {
Deno.renameSync(
pathModule.toNamespacedPath(oldPath),
pathModule.toNamespacedPath(newPath),
);
Deno.renameSync(oldPath, newPath);
} catch (err) {
throw denoErrorToNodeError(err as Error, {
syscall: "rename",
Expand Down
5 changes: 2 additions & 3 deletions ext/node/polyfills/_fs/_fs_rmdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
validateRmOptions,
validateRmOptionsSync,
} from "ext:deno_node/internal/fs/utils.mjs";
import { toNamespacedPath } from "node:path";
import {
denoErrorToNodeError,
ERR_FS_RMDIR_ENOTDIR,
Expand All @@ -37,7 +36,7 @@ export function rmdir(
optionsOrCallback: rmdirOptions | rmdirCallback,
maybeCallback?: rmdirCallback,
) {
path = toNamespacedPath(getValidatedPath(path) as string);
path = getValidatedPath(path) as string;

const callback = typeof optionsOrCallback === "function"
? optionsOrCallback
Expand Down Expand Up @@ -101,7 +100,7 @@ export function rmdirSync(path: string | Buffer | URL, options?: rmdirOptions) {
}

try {
Deno.removeSync(toNamespacedPath(path as string), {
Deno.removeSync(path as string, {
recursive: options?.recursive,
});
} catch (err: unknown) {
Expand Down
5 changes: 2 additions & 3 deletions ext/node/polyfills/_fs/_fs_unlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { primordials } from "ext:core/mod.js";
import { denoErrorToNodeError } from "ext:deno_node/internal/errors.ts";
import { getValidatedPathToString } from "ext:deno_node/internal/fs/utils.mjs";
import { validateFunction } from "ext:deno_node/internal/validators.mjs";
import * as pathModule from "node:path";

const {
PromisePrototypeThen,
Expand All @@ -20,7 +19,7 @@ export function unlink(
validateFunction(callback, "callback");

PromisePrototypeThen(
Deno.remove(pathModule.toNamespacedPath(path)),
Deno.remove(path),
() => callback(),
(err: Error) =>
callback(denoErrorToNodeError(err, { syscall: "unlink", path })),
Expand All @@ -34,7 +33,7 @@ export const unlinkPromise = promisify(unlink) as (
export function unlinkSync(path: string | Buffer | URL): void {
path = getValidatedPathToString(path);
try {
Deno.removeSync(pathModule.toNamespacedPath(path));
Deno.removeSync(path);
} catch (err) {
throw denoErrorToNodeError(err as Error, { syscall: "unlink", path });
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// regression test for https://github.com/denoland/deno/issues/30534
// as this should not require all write permissions
{
"if": "windows",
"tempDir": true,
"args": "run --allow-write=./env.js main.ts",
"output": ""
}
6 changes: 6 additions & 0 deletions tests/specs/node/windows_write_stream_permissions/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createWriteStream } from "node:fs";
const outputWriteStream = createWriteStream("./env.js", {
encoding: "utf-8",
});

outputWriteStream.write("something", "utf-8");
Loading