提交 97cd1902 编写于 作者: J Johannes Rieken

add pipe name generator

上级 70560a28
......@@ -10,6 +10,18 @@ import { TPromise } from 'vs/base/common/winjs.base';
import Event, { Emitter, once, mapEvent } from 'vs/base/common/event';
import { fromEventEmitter } from 'vs/base/node/event';
import { IMessagePassingProtocol, ClientConnectionEvent, IPCServer, IPCClient } from 'vs/base/parts/ipc/common/ipc';
import { join } from 'path';
import { tmpdir } from 'os';
export function generateRandomPipeName(): string {
let randomName = 'vscode-' + Math.floor(Math.random() * 10000).toString(16);
if (process.platform === 'win32') {
return '\\\\.\\pipe\\' + randomName + '-sock';
} else {
// Mac/Unix: use socket file
return join(tmpdir(), randomName + '.sock');
}
}
function bufferIndexOf(buffer: Buffer, value: number, start = 0) {
while (start < buffer.length && buffer[start] !== value) {
......@@ -136,4 +148,4 @@ export function connect(hook: any, clientId: string): TPromise<Client> {
socket.once('error', e);
});
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册