mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
a099a8a25c
If using dynamic parameters, workspace tags are extracted using `coder/preview`.
20 lines
350 B
Go
20 lines
350 B
Go
package archivefs
|
|
|
|
import (
|
|
"archive/zip"
|
|
"io"
|
|
"io/fs"
|
|
|
|
"github.com/spf13/afero"
|
|
"github.com/spf13/afero/zipfs"
|
|
)
|
|
|
|
// FromZipReader creates a read-only in-memory FS
|
|
func FromZipReader(r io.ReaderAt, size int64) (fs.FS, error) {
|
|
zr, err := zip.NewReader(r, size)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return afero.NewIOFS(zipfs.New(zr)), nil
|
|
}
|