Move more code to /common/

This commit is contained in:
Alex Dima
2019-03-25 19:05:26 +01:00
parent 2b0b602af8
commit 3ba93e8aac
7 changed files with 158 additions and 108 deletions

View File

@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ResolvedAuthority, IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
export class RemoteAuthorityResolverService implements IRemoteAuthorityResolverService {
_serviceBrand: any;
constructor() {
}
resolveAuthority(authority: string): Promise<ResolvedAuthority> {
if (authority.indexOf(':') >= 0) {
const pieces = authority.split(':');
return Promise.resolve({ authority, host: pieces[0], port: parseInt(pieces[1], 10) });
}
return Promise.resolve({ authority, host: authority, port: 80 });
}
setResolvedAuthority(resolvedAuthority: ResolvedAuthority) {
throw new Error(`Not implemented`);
}
setResolvedAuthorityError(authority: string, err: any): void {
throw new Error(`Not implemented`);
}
}

View File

@@ -9,6 +9,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { FileChangeType, FileDeleteOptions, FileOverwriteOptions, FileSystemProviderCapabilities, FileType, FileWriteOptions, IFileChange, IFileSystemProvider, IStat, IWatchOptions } from 'vs/platform/files/common/files';
import { VSBuffer } from 'vs/base/common/buffer';
export const REMOTE_FILE_SYSTEM_CHANNEL_NAME = 'remotefilesystem';
@@ -71,20 +72,17 @@ export class RemoteExtensionsFileSystemProvider extends Disposable implements IF
// --- forwarding calls
private static _asBuffer(data: Uint8Array): Buffer {
return Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
}
stat(resource: URI): Promise<IStat> {
return this._channel.call('stat', [resource]);
}
readFile(resource: URI): Promise<Uint8Array> {
return this._channel.call('readFile', [resource]);
async readFile(resource: URI): Promise<Uint8Array> {
const buff = <VSBuffer>await this._channel.call('readFile', [resource]);
return buff.buffer;
}
writeFile(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void> {
const contents = RemoteExtensionsFileSystemProvider._asBuffer(content);
const contents = VSBuffer.wrap(content);
return this._channel.call('writeFile', [resource, contents, opts]);
}