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

Commit

Permalink
Remove incorrect \\?\ prefix on windows and fs.promises fixes (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Mar 25, 2021
1 parent 663f3f0 commit 1c219c8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion prelude/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,24 @@ function payloadFileSync(pointer) {
accessFromSnapshot(path, callback);
};

// ///////////////////////////////////////////////////////////////
// promises ////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////

if (fs.promises !== undefined) {
var util = require('util');
fs.promises.open = util.promisify(fs.open);
fs.promises.read = util.promisify(fs.read);
fs.promises.write = util.promisify(fs.write);
fs.promises.readFile = util.promisify(fs.readFile);
fs.promises.readdir = util.promisify(fs.readdir);
fs.promises.realpath = util.promisify(fs.realpath);
fs.promises.stat = util.promisify(fs.stat);
fs.promises.lstat = util.promisify(fs.lstat);
fs.promises.fstat = util.promisify(fs.fstat);
fs.promises.access = util.promisify(fs.access);
}

// ///////////////////////////////////////////////////////////////
// INTERNAL //////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1688,9 +1706,14 @@ function payloadFileSync(pointer) {
var ancestor = {};
ancestor.dlopen = process.dlopen;

function revertMakingLong(f) {
if (/^\\\\\?\\/.test(f)) return f.slice(4);
return f;
}

process.dlopen = function () {
const args = cloneArgs(arguments);
const modulePath = args[1];
const modulePath = revertMakingLong(args[1]);
const moduleDirname = require('path').dirname(modulePath);
if (insideSnapshot(modulePath)) {
// Node addon files and .so cannot be read with fs directly, they are loaded with process.dlopen which needs a filesystem path
Expand Down

0 comments on commit 1c219c8

Please sign in to comment.