(
targetPath: string | vscode.Uri,
type: vscode.FileType,
)
| 54 | // Check that the file or directory exists in an asynchronous manner that relies |
| 55 | // solely on the VS Code API, not Node's fs library, ignoring symlinks. |
| 56 | async function checkIfFileOrDirectoryExists( |
| 57 | targetPath: string | vscode.Uri, |
| 58 | type: vscode.FileType, |
| 59 | ): Promise<boolean> { |
| 60 | if (targetPath === "") { |
| 61 | return false; |
| 62 | } |
| 63 | try { |
| 64 | const stat: vscode.FileStat = await vscode.workspace.fs.stat( |
| 65 | targetPath instanceof vscode.Uri |
| 66 | ? targetPath |
| 67 | : vscode.Uri.file(targetPath), |
| 68 | ); |
| 69 | return (stat.type & type) !== 0; |
| 70 | } catch { |
| 71 | return false; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | export async function checkIfFileExists( |
| 76 | filePath: string | vscode.Uri, |
no outgoing calls
no test coverage detected