@@ -84,15 +84,13 @@ export class FileSystemCommon {
84
84
85
85
async exists ( path : Uri | string , fileType ?: vscode . FileType ) : Promise < boolean > {
86
86
path = FileSystemCommon . getUri ( path )
87
- const stat = await this . stat ( path )
88
-
89
- // No specific filetype, so only check if anything exists
90
- if ( fileType === undefined ) {
91
- return stat !== undefined
87
+ try {
88
+ const stat = await this . stat ( path )
89
+ // check filetype if it was given
90
+ return fileType === undefined ? true : stat . type === fileType
91
+ } catch ( e ) {
92
+ return false
92
93
}
93
-
94
- // Check if file exists and is expected filetype
95
- return stat === undefined ? false : stat . type === fileType
96
94
}
97
95
98
96
async fileExists ( path : Uri | string ) : Promise < boolean > {
@@ -111,16 +109,9 @@ export class FileSystemCommon {
111
109
/**
112
110
* The stat of the file, undefined if the file does not exist, otherwise an error is thrown.
113
111
*/
114
- async stat ( uri : vscode . Uri | string ) : Promise < vscode . FileStat | undefined > {
112
+ async stat ( uri : vscode . Uri | string ) : Promise < vscode . FileStat > {
115
113
const path = FileSystemCommon . getUri ( uri )
116
- try {
117
- return await fs . stat ( path )
118
- } catch ( err ) {
119
- if ( err instanceof vscode . FileSystemError && err . code === 'FileNotFound' ) {
120
- return undefined
121
- }
122
- throw err
123
- }
114
+ return await fs . stat ( path )
124
115
}
125
116
126
117
async delete ( uri : vscode . Uri | string ) : Promise < void > {
0 commit comments