Skip to content

Commit

Permalink
feat: add new EmptyFileSystemProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean authored and CGNonofr committed Apr 18, 2024
1 parent df27332 commit cb6acd2
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/service-override/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,43 @@ class DelegateFileSystemProvider implements IFileSystemProvider {
}
}

class EmptyFileSystemProvider implements IFileSystemProviderWithFileReadWriteCapability {
async readFile (): Promise<Uint8Array> {
throw createFileSystemProviderError('Not found', FileSystemProviderErrorCode.FileNotFound)
}

async writeFile (): Promise<void> {
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions)
}

capabilities = FileSystemProviderCapabilities.FileReadWrite | FileSystemProviderCapabilities.PathCaseSensitive
onDidChangeCapabilities = Event.None
onDidChangeFile = Event.None
watch (): IDisposable {
return Disposable.None
}

async stat (): Promise<IStat> {
throw createFileSystemProviderError('Not found', FileSystemProviderErrorCode.FileNotFound)
}

async mkdir (): Promise<void> {
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions)
}

async readdir (): Promise<[string, FileType][]> {
throw createFileSystemProviderError('Not found', FileSystemProviderErrorCode.FileNotFound)
}

async delete (): Promise<void> {
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions)
}

async rename (): Promise<void> {
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions)
}
}

const overlayFileSystemProvider = new OverlayFileSystemProvider()
overlayFileSystemProvider.register(0, new MkdirpOnWriteInMemoryFileSystemProvider())

Expand Down Expand Up @@ -676,5 +713,6 @@ export {
RegisteredReadOnlyFile,
RegisteredMemoryFile,
DelegateFileSystemProvider,
OverlayFileSystemProvider
OverlayFileSystemProvider,
EmptyFileSystemProvider
}

0 comments on commit cb6acd2

Please sign in to comment.