-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose 'reading' API for file system providers #48034
Comments
This would be extremely compelling for Live Share, since it would allow extensions to access files even on the “guest” side. |
This would also be very valuable for my new proof-of-concept extension RemoteHub |
If I understand correctly, even with this, will each extension developer still have to write something like this? async function writeToAnywhere(uri, blob) {
if (uri.scheme === 'file')
await require('fs.promise').writeFile(uri.fsPath(), blob);
else
await vscode.workspace.getFileSystemProviderByScheme(uri.scheme).write(uri, blob);
} I'm writing an extension that deals with binary files, and I'd love to see an abstraction layer that works transparently with any URI regardless of the scheme, as suggested in #51528. There is already a Node's |
No. The goal is to enable something like this |
…ons. Summary: This makes it so that the `FileSystemProvider` for the `big-dig` scheme can be used by other extensions (providing a workaround for microsoft/vscode#48034). Here is an example of how to leverage this: ``` function getFileSystemProvider(): vscode.FileSystemProvider | null { const bigDig = vscode.extensions.getExtension("Facebook.big-dig-vscode"); if (bigDig == null) { return null; } if (!bigDig.isActive) { // Alternatively, make this method async and do: // return (await bigDig.activate()).fileSystemProvider; return null; } return bigDig.exports.fileSystemProvider; } ``` Note that this technique of making objects from the `big-dig-vscode` extension could be used more generally as the basis for a Big Dig client library so that other extensions can talk to Big Dig, as appropriate. One common case that has been discussed is language extensions reading from the user's `settings.json` to determine what sorts of extra arguments to add to the `initializationOptions`. Reviewed By: siegebell Differential Revision: D9419766 fbshipit-source-id: d705cc03f71b01e8cefead99a197f8b307c2ad5d
If you are the one creating the |
My extensions Email Viewer and ZIP File System would also benefit from this because both deal with mapping files to virtual file system and reading the original file should be possible from other providers not just If one wants to avoid using Node to read the file, it is possible to hack around it by having VS Code open the |
This comment has been minimized.
This comment has been minimized.
Hey, I was wondering if there was any progress on this issue or what the community could do to make this feature come to life. |
Looks like we are nearing the goal. According to this, plain local workspaces will be based on |
Very simple API proposal (which isn't that simple to implement tho) would be to expose a export namespace workspace {
export const fs: FileSystemProvider
} which then can be used like this |
A little more than just the |
Can this API read the directory of file located in the remote using VSCode Remote? It doesn't seem to able to if my extension is running on local. Is there any API I can use so that I can query the file system of the remote without having to install the extension in the remote? |
@stevenguh Yes, that's what this API can be used for. In essence, every resource that VS Code can open, can be opened via this API. |
It took me some tinkering to get it working. To access the remote file from an extension installed on a local host, you need to have a right |
Yes, the easiest is to "derive" a URI from an active editor, open document, or the workspace |
I think it would be great if that information is documented somewhere |
Yeah, missing docs/samples are the reason why this issue is still open... I am very open for ideas/suggestions. So far on my list I have
|
Sounds good, thank you for all the work. Maybe a sub-bullet for "how to get the 'first' uri constructed" should have some examples of using this API for ssh remote with an extension on the host machine. And another sub-bullet for path.posix-utils, I found the use of posix path on windows environment is kinda weird. Maybe that's worth pointing it out. (I am new to this, maybe this is a norm in the vs code extension community) Charts like the ones in https://nodejs.org/api/path.html#path_path_posix could be useful in explaining the posix path on windows? Also, your doc on the proposed API is missing the information the possible exceptions that each method can throw like the doc in FileSystemProvider? As well, the way to catch specific error is not clear. |
started some sample work here: microsoft/vscode-extension-samples#195 |
That looks like a good start. I have a side question, not sure if you would be able to answer. |
Yes, I tried to clarify that earlier: everything the editor can do, can be done by this API |
With #47475 we will finalise the file system provider API. With that the only (reading) client of that API will be VS Code itself. We should also allow extensions to use the API, e.g. read a file/folder that's served via a contributed file system provider.
The text was updated successfully, but these errors were encountered: