allow to define byte-offset and byte-count when reading from a provider

This commit is contained in:
Johannes Rieken
2017-09-21 17:38:02 +02:00
parent 424e1ebc28
commit 40dd269a72
6 changed files with 13 additions and 14 deletions

View File

@@ -90,9 +90,9 @@ class RemoteFileSystemProvider implements IFileSystemProvider {
stat(resource: URI): TPromise<IStat, any> {
return this._proxy.$stat(this._handle, resource);
}
read(resource: URI, progress: IProgress<Uint8Array>): TPromise<void, any> {
read(resource: URI, offset: number, count: number, progress: IProgress<Uint8Array>): TPromise<number, any> {
this._reads.set(resource.toString(), progress);
return this._proxy.$read(this._handle, resource);
return this._proxy.$read(this._handle, offset, count, resource);
}
reportFileChunk(resource: URI, chunk: number[]): void {
this._reads.get(resource.toString()).report(Buffer.from(chunk));

View File

@@ -481,7 +481,7 @@ export interface ExtHostWorkspaceShape {
export interface ExtHostFileSystemShape {
$utimes(handle: number, resource: URI, mtime: number): TPromise<IStat>;
$stat(handle: number, resource: URI): TPromise<IStat>;
$read(handle: number, resource: URI): TPromise<void>;
$read(handle: number, offset: number, count: number, resource: URI): TPromise<number>;
$write(handle: number, resource: URI, content: number[]): TPromise<void>;
$unlink(handle: number, resource: URI): TPromise<void>;
$move(handle: number, resource: URI, target: URI): TPromise<IStat>;

View File

@@ -48,12 +48,13 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
$stat(handle: number, resource: URI): TPromise<IStat, any> {
return asWinJsPromise(token => this._provider.get(handle).stat(resource));
}
$read(handle: number, resource: URI): TPromise<void> {
return asWinJsPromise(token => this._provider.get(handle).read(resource, {
report: (chunk) => {
$read(handle: number, offset: number, count: number, resource: URI): TPromise<number> {
const progress = {
report: chunk => {
this._proxy.$reportFileChunk(handle, resource, [].slice.call(chunk));
}
}));
};
return asWinJsPromise(token => this._provider.get(handle).read(resource, offset, count, progress));
}
$write(handle: number, resource: URI, content: number[]): TPromise<void, any> {
return asWinJsPromise(token => this._provider.get(handle).write(resource, Buffer.from(content)));