Add exists() function to FileSystemProvider
See original GitHub issueWhen trying to write a file to a file system, it’s often helpful to warn the user when that file already exists (and then prompt to overwrite, skip, or cancel the operation). The FileSystemProvider interface has a stat() method that can be used for that purpose, but it throws when the file does not exist. However, asking for information about a file that doesn’t exist is not really an exceptional case, and trapping an exception trying to determine what it represents–that is, the lack of the file or some other error–is less than ideal. The stat() method could just return undefined when the file does not exist but, that would be a breaking change.
Instead, I propose adding a exists(): Thenable<boolean> function to FileSystemProvider that returns a simple yes/no. (If yes, and more details were required, the extension could then call stat().)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
fs.existsis deprecated: https://nodejs.org/api/fs.html#fs_fs_exists_path_callbackfs.accessmay be a preferred alternative: https://nodejs.org/api/fs.html#fs_fs_access_path_mode_callbackLet’s make sure this doesn’t disappear