Update pipe-ipc.js

This commit is contained in:
Namhyeon Go 2023-09-20 14:59:30 +09:00 committed by GitHub
parent 30f16cf3e8
commit 3999bcc171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,16 +69,18 @@ function createADO() {
return CreateObject("ADODB.Stream"); return CreateObject("ADODB.Stream");
} }
function SetPositionADO(ado, position) { function AdoConvertToStream(ado, position) {
var newAdo = createADO(); position = (position !== "undefined" ? position : 0);
newAdo.Type = adTypeBinary;
newAdo.Mode = adModeReadWrite; var newAdo = createADO();
newAdo.Open(); newAdo.Type = adTypeBinary;
ado.Position = position; newAdo.Mode = adModeReadWrite;
ado.CopyTo(newAdo); newAdo.Open();
ado.Flush(); ado.Position = position;
ado.Close(); ado.CopyTo(newAdo);
return newAdo; ado.Flush();
ado.Close();
return newAdo;
} }
function PipeIPC() { function PipeIPC() {
@ -167,7 +169,7 @@ function PipeIPC() {
} }
// with iomode (default: ForAppending) // with iomode (default: ForAppending)
var iomode = (iomode !== "undefined" ? ForAppending : iomode); iomode = (iomode !== "undefined" ? ForAppending : iomode);
this.openRecorder(iomode); this.openRecorder(iomode);
}; };
@ -197,7 +199,7 @@ function PipeIPC() {
this.write = function(message, iomode) { this.write = function(message, iomode) {
// with iomode (default: ForAppending) // with iomode (default: ForAppending)
var iomode = (iomode !== "undefined" ? ForAppending : iomode); iomode = (iomode !== "undefined" ? ForAppending : iomode);
if (this.savefile != null) { if (this.savefile != null) {
this.record(message); this.record(message);
@ -273,7 +275,7 @@ function PipeIPC() {
ado.Charset = charset; ado.Charset = charset;
ado.Open(); ado.Open();
ado.WriteText(str); ado.WriteText(str);
ado = SetPositionADO(ado, 3); ado = AdoConvertToStream(ado, 3);
ado.SaveToFile(dst, adSaveCreateOverWrite); ado.SaveToFile(dst, adSaveCreateOverWrite);
ado.Close(); ado.Close();
@ -405,7 +407,7 @@ exports.adSaveCreateNotExist = adSaveCreateNotExist;
exports.adSaveCreateOverWrite = adSaveCreateOverWrite; exports.adSaveCreateOverWrite = adSaveCreateOverWrite;
exports.adModeReadWrite = adModeReadWrite; exports.adModeReadWrite = adModeReadWrite;
exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.9"; exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.10";
exports.AUTHOR = "abuse@catswords.net"; exports.AUTHOR = "abuse@catswords.net";
exports.global = global; exports.global = global;
exports.require = require; exports.require = require;