MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / requestFileContent

Method requestFileContent

src/liveShare/index.ts:308–326  ·  view source on GitHub ↗
(file: fs.PathLike | number, encoding?: string)

Source from the content-addressed store, hash-verified

306 public async requestFileContent(file: fs.PathLike | number): Promise<Buffer>;
307 public async requestFileContent(file: fs.PathLike | number, encoding: string): Promise<string>;
308 public async requestFileContent(file: fs.PathLike | number, encoding?: string): Promise<string | Buffer | undefined> {
309 if (this._isStarted) {
310 if (encoding !== undefined) {
311 const content: string | unknown = await liveShareRequest(Callback.GetFileContent, file, encoding);
312 if (typeof content === 'string') {
313 return content;
314 } else {
315 console.error('[GuestService] failed to retrieve file content (not of type "string")');
316 }
317 } else {
318 const content: Buffer | unknown = await liveShareRequest(Callback.GetFileContent, file);
319 if (content) {
320 return content as Buffer;
321 } else {
322 console.error('[GuestService] failed to retrieve file content (not of type "Buffer")');
323 }
324 }
325 }
326 }
327
328 public async requestHelpContent(file: string): Promise<HelpFile | undefined> {
329 const content: string | null | unknown = await liveShareRequest(Callback.GetHelpFileContent, file);

Callers 2

readContentFunction · 0.80
showDataViewFunction · 0.80

Calls 1

liveShareRequestFunction · 0.90

Tested by

no test coverage detected