Debian Codegraph @

helper/temporal/temporal.go

raw symbols SCIP
1 package temporal
2
3 import (
4 "github.com/go-git/go-billy/v5"
5 "github.com/go-git/go-billy/v5/util"
6 )
7
8 // Temporal is a helper that implements billy.TempFile over any filesystem.
9 type Temporal struct {
10 billy.Filesystem
11 defaultDir string
12 }
13
14 // New creates a new filesystem wrapping up 'fs' the intercepts the calls to
15 // the TempFile method. The param defaultDir is used as default directory were
16 // the tempfiles are created.
17 func New(fs billy.Filesystem, defaultDir string) billy.Filesystem {
18 return &Temporal{
19 Filesystem: fs,
20 defaultDir: defaultDir,
21 }
22 }
23
24 func (h *Temporal) TempFile(dir, prefix string) (billy.File, error) {
25 if dir == "" {
26 dir = h.defaultDir
27 }
28
29 return util.TempFile(h.Filesystem, dir, prefix)
30 }