fileService.ts ×11

Frontier kind: Code frontier

unlabeled · c_2b5a2b5ab8c4

619 tests · 11443 LOC · 44 files · introduces 0 tests · 35 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges35 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1789 ranges11443 lines · 44 files · Browse complete extent
All tests (intent)
619 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 35 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/files/common/fileService.ts 35 introduced LOC · 11 ranges

Open complete file

539
540 async readFile(resource: URI, options?: IReadFileOptions, token?: CancellationToken): Promise<IFileContent> {
541 > const provider = await this.withReadProvider(resource); fileService.ts
542 >
543 > if (options?.atomic) {
544 return this.doReadFileAtomic(provider, resource, options, token);
545 }
547 > return this.doReadFile(provider, resource, options, token);
548 > }
549
550 private async doReadFileAtomic(provider: IFileSystemProviderWithFileReadWriteCapability | IFileSystemProviderWithOpenReadWriteCloseCapability | IFileSystemProviderWithFileReadStreamCapability, resource: URI, options?: IReadFileOptions, token?: CancellationToken): Promise<IFileContent> {
562
563 private async doReadFile(provider: IFileSystemProviderWithFileReadWriteCapability | IFileSystemProviderWithOpenReadWriteCloseCapability | IFileSystemProviderWithFileReadStreamCapability, resource: URI, options?: IReadFileOptions, token?: CancellationToken): Promise<IFileContent> {
564 > const stream = await this.doReadFileStream(provider, resource, { fileService.ts
565 > ...options,
566 > // optimization: since we know that the caller does not
567 > // care about buffering, we indicate this to the reader.
568 > // this reduces all the overhead the buffered reading
569 > // has (open, read, close) if the provider supports
570 > // unbuffered reading.
571 > preferUnbuffered: true
572 > }, token);
573
574 return {
576 value: await streamToBuffer(stream.value)
577 };
578 > } fileService.ts
579
580 async readFileStream(resource: URI, options?: IReadFileStreamOptions, token?: CancellationToken): Promise<IFileStreamContent> {
625 (hasReadWriteCapability(provider) && readFileOptions?.preferUnbuffered) // unbuffered read is preferred
626 ) {
627 > fileStream = this.readFileUnbuffered(provider, resource, readFileOptions); fileService.ts
628 > }
629
630 // read streamed (always prefer over primitive buffered read)
698
699 private readFileUnbuffered(provider: IFileSystemProviderWithFileReadWriteCapability | IFileSystemProviderWithFileAtomicReadCapability, resource: URI, options?: IReadFileOptions & IReadFileStreamOptions): VSBufferReadableStream {
700 > const stream = newWriteableStream<VSBuffer>(data => VSBuffer.concat(data)); fileService.ts
701 >
702 > // Read the file into the stream async but do not wait for
703 > // this to complete because streams work via events
704 > (async () => {
705 > try {
706 > let buffer: Uint8Array;
707 > if (options?.atomic && hasFileAtomicReadCapability(provider)) {
708 buffer = await provider.readFile(resource, { atomic: true });
709 > } else { fileService.ts
710 > buffer = await provider.readFile(resource);
711 }
712
713 // respect position option
714 > if (typeof options?.position === 'number') { fileService.ts
715 buffer = buffer.slice(options.position);
716 }
717
718 // respect length option
719 > if (typeof options?.length === 'number') { fileService.ts
720 buffer = buffer.slice(0, options.length);
721 }
726 // End stream with data
727 stream.end(VSBuffer.wrap(buffer));
728 > } catch (err) { fileService.ts
729 stream.error(err);
730 stream.end();
731 }
732 > })(); fileService.ts
733 >
734 > return stream;
735 > }
736
737 private async validateReadFile(resource: URI, options?: IReadFileStreamOptions): Promise<IFileStatWithMetadata> {