You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

temporal.go 719B

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