mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 15:04:58 +00:00
Update pipe-ipc.js
This commit is contained in:
parent
cbac701e7e
commit
f22364b2f9
|
@ -109,7 +109,7 @@ function AdoConvertToStream(ado, position) {
|
|||
|
||||
function PipeIPC() {
|
||||
this.path = "data\\.pipe_:pipename";
|
||||
this.delimiter = "\r\n";
|
||||
this.delimiter = '\r\n';
|
||||
this.reader = null;
|
||||
this.writer = null;
|
||||
this.recorder = null;
|
||||
|
@ -181,6 +181,8 @@ function PipeIPC() {
|
|||
};
|
||||
|
||||
this.startRecorder = function(filename, iomode) {
|
||||
iomode = (iomode !== "undefined" ? ForAppending : iomode); // default: ForAppending
|
||||
|
||||
this.savefile = filename;
|
||||
this.tmpfile = this.savefile + ".tmp";
|
||||
|
||||
|
@ -198,8 +200,7 @@ function PipeIPC() {
|
|||
}
|
||||
}
|
||||
|
||||
// with iomode (default: ForAppending)
|
||||
iomode = (iomode !== "undefined" ? ForAppending : iomode);
|
||||
// open a recorder
|
||||
this.openRecorder(iomode);
|
||||
};
|
||||
|
||||
|
@ -224,16 +225,11 @@ function PipeIPC() {
|
|||
};
|
||||
|
||||
this._write = function(message) {
|
||||
this.writer.Write(message + this.delimiter);
|
||||
this.writer.Write(message);
|
||||
};
|
||||
|
||||
this.write = function(message, iomode) {
|
||||
// with iomode (default: ForAppending)
|
||||
iomode = (iomode !== "undefined" ? ForAppending : iomode);
|
||||
|
||||
if (this.savefile != null) {
|
||||
this.record(message);
|
||||
}
|
||||
iomode = (iomode !== "undefined" ? ForAppending : iomode); // default: ForAppending
|
||||
|
||||
var isWritten = false;
|
||||
while (!isWritten) {
|
||||
|
@ -250,6 +246,11 @@ function PipeIPC() {
|
|||
}
|
||||
}
|
||||
|
||||
// record the last message
|
||||
if (isWritten && this.savefile != null) {
|
||||
this.record(message);
|
||||
}
|
||||
|
||||
return isWritten;
|
||||
};
|
||||
|
||||
|
@ -355,7 +356,7 @@ function PipeIPC() {
|
|||
|
||||
this.read = function() {
|
||||
var isRead = false;
|
||||
var text = "";
|
||||
var text = '';
|
||||
|
||||
while (!isRead) {
|
||||
try {
|
||||
|
@ -380,7 +381,6 @@ function PipeIPC() {
|
|||
this.destroy = function() {
|
||||
this.close();
|
||||
createFSO().DeleteFile(this.path);
|
||||
|
||||
};
|
||||
|
||||
this.readTextFromFile = function(filename, charset) {
|
||||
|
@ -413,6 +413,11 @@ function PipeIPC() {
|
|||
this.loadFromFile = function(filename, charset) {
|
||||
this.write(this.readTextFromFile(filename, charset), ForWriting);
|
||||
};
|
||||
|
||||
this.reload = function(charset) {
|
||||
charset = (typeof charset !== "undefined" ? this.charset : charset);
|
||||
this.loadFromFile(this.path, charset);
|
||||
};
|
||||
}
|
||||
|
||||
exports.create = function() {
|
||||
|
@ -440,7 +445,7 @@ exports.adSaveCreateNotExist = adSaveCreateNotExist;
|
|||
exports.adSaveCreateOverWrite = adSaveCreateOverWrite;
|
||||
exports.adModeReadWrite = adModeReadWrite;
|
||||
|
||||
exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.11";
|
||||
exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.12";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user