restic/src/restic/fs/file_unix.go

38 lines
893 B
Go
Raw Normal View History

// +build !windows
package fs
2017-05-10 19:48:22 +02:00
import (
"io/ioutil"
"os"
)
// fixpath returns an absolute path on windows, so restic can open long file
// names.
func fixpath(name string) string {
return name
}
// MkdirAll creates a directory named path, along with any necessary parents,
// and returns nil, or else returns an error. The permission bits perm are used
// for all directories that MkdirAll creates. If path is already a directory,
// MkdirAll does nothing and returns nil.
func MkdirAll(path string, perm os.FileMode) error {
return os.MkdirAll(fixpath(path), perm)
}
2017-05-10 19:48:22 +02:00
// 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 = ioutil.TempFile(dir, prefix)
if err != nil {
return nil, err
}
if err = os.Remove(f.Name()); err != nil {
return nil, err
}
return f, nil
}