Skip to content

Commit

Permalink
* 格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
weolar committed Sep 25, 2024
1 parent 317bebd commit 2443d47
Show file tree
Hide file tree
Showing 225 changed files with 76,677 additions and 70,926 deletions.
54 changes: 53 additions & 1 deletion node/lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ var readSyncWarned = false;
fs.readSync = function(fd, buffer, offset, length, position) {
var legacy = false;
var encoding;

if (!(buffer instanceof Buffer)) {
// legacy string interface (fd, length, position, encoding, callback)
readSyncWarned = printDeprecation('fs.readSync\'s legacy String interface' +
Expand Down Expand Up @@ -1827,6 +1826,23 @@ fs.realpath = function realpath(p, options, callback) {
}
};

function getOptions(options, defaultOptions) {
if (options === null || options === undefined ||
typeof options === 'function') {
return defaultOptions;
}
return options;
}

fs.realpath.native = (path, options, callback) => {
callback = makeCallback(callback || options);
options = getOptions(options, {});
//path = /getValidatedPath(path);
const req = new FSReqCallback();
req.oncomplete = callback;
return binding.realpath(path, options.encoding, req);
};

fs.mkdtemp = function(prefix, options, callback) {
if (!prefix || typeof prefix !== 'string')
throw new TypeError('filename prefix is required');
Expand Down Expand Up @@ -1867,6 +1883,42 @@ fs.mkdtempSync = function(prefix, options) {
return binding.mkdtemp(prefix + 'XXXXXX', options.encoding);
};

fs.copyFile = function(src, dest, flags, callback) {
if (typeof flags === 'function') {
callback = flags;
flags = 0;
} else if (typeof callback !== 'function') {
throw new ERR_INVALID_CALLBACK();
}

//src = toPathIfFileURL(src);
//dest = toPathIfFileURL(dest);
//validatePath(src, 'src');
//validatePath(dest, 'dest');

src = pathModule._makeLong(src);
dest = pathModule._makeLong(dest);
flags = flags | 0;
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
binding.copyFile(src, dest, flags, req);
}


fs.copyFileSync = function(src, dest, flags) {
//src = toPathIfFileURL(src);
//dest = toPathIfFileURL(dest);
//validatePath(src, 'src');
//validatePath(dest, 'dest');

const ctx = { path: src, dest }; // non-prefixed

src = pathModule._makeLong(src);
dest = pathModule._makeLong(dest);
flags = flags | 0;
binding.copyFile(src, dest, flags, undefined, ctx);
//handleErrorFromBinding(ctx);
}

var pool;

Expand Down
2 changes: 1 addition & 1 deletion node/lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
setupGlobalConsole();
}

setupAsarSupport();
setupAsarSupport(); // weolar

const _process = NativeModule.require('internal/process');

Expand Down
15 changes: 14 additions & 1 deletion node/lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const active = exports.active = function(item) {

// Internal APIs that need timeouts should use `_unrefActive()` instead of
// `active()` so that they do not unnecessarily keep the process open.
exports._unrefActive = function(item) {
const _unrefActive = exports._unrefActive = function(item) {
insert(item, true);
};

Expand Down Expand Up @@ -459,6 +459,7 @@ function Timeout(after, callback, args) {
this._onTimeout = callback;
this._timerArgs = args;
this._repeat = null;
this.kRefed = null;
}


Expand All @@ -468,8 +469,18 @@ function unrefdHandle() {
this.owner.close();
}

Timeout.prototype.refresh = function() {
if (this.kRefed)
active(this);
else
_unrefActive(this);

return this;
}

Timeout.prototype.unref = function() {
this.kRefed = false;

if (this._handle) {
this._handle.unref();
} else if (typeof this._onTimeout === 'function') {
Expand Down Expand Up @@ -497,6 +508,8 @@ Timeout.prototype.unref = function() {
};

Timeout.prototype.ref = function() {
this[kRefed] = true;

if (this._handle)
this._handle.ref();
return this;
Expand Down
Loading

0 comments on commit 2443d47

Please sign in to comment.