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

@@ -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)));