Files
restic/internal/fileio/file_unix.go
T
Michael Eischer 4d1b9cef63 internal/fileio: extract low-level file I/O from internal/fs
Move TempFile and PreallocateFile into internal/fileio. internal/fs
primarily focuses on converting between data.Node and the actual
filesystem state. Extract the two methods to not pull in unnecessary
dependencies.
2026-06-20 17:48:35 +02:00

23 lines
370 B
Go

//go:build !windows
package fileio
import (
"os"
)
// TempFile creates a temporary file which has already been deleted (on
// supported platforms)
func TempFile(dir, prefix string) (f *os.File, err error) {
f, err = os.CreateTemp(dir, prefix)
if err != nil {
return nil, err
}
if err = os.Remove(f.Name()); err != nil {
return nil, err
}
return f, nil
}