pkg/ioutils: unify TempDir implementation
This allows us to maintain a single GoDoc string to describe what it's used for. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
2e67c85c13
commit
3314f4ef09
2 changed files with 7 additions and 12 deletions
|
@ -1,11 +0,0 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ioutils // import "github.com/docker/docker/pkg/ioutils"
|
||||
|
||||
import "os"
|
||||
|
||||
// TempDir on Unix systems is equivalent to os.MkdirTemp.
|
||||
func TempDir(dir, prefix string) (string, error) {
|
||||
return os.MkdirTemp(dir, prefix)
|
||||
}
|
|
@ -2,15 +2,21 @@ package ioutils // import "github.com/docker/docker/pkg/ioutils"
|
|||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/docker/docker/pkg/longpath"
|
||||
)
|
||||
|
||||
// TempDir is the equivalent of os.MkdirTemp, except that the result is in Windows longpath format.
|
||||
// TempDir is the equivalent of [os.MkdirTemp], except that on Windows
|
||||
// the result is in Windows longpath format. On Unix systems it is
|
||||
// equivalent to [os.MkdirTemp].
|
||||
func TempDir(dir, prefix string) (string, error) {
|
||||
tempDir, err := os.MkdirTemp(dir, prefix)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if runtime.GOOS != "windows" {
|
||||
return tempDir, nil
|
||||
}
|
||||
return longpath.AddPrefix(tempDir), nil
|
||||
}
|
Loading…
Reference in a new issue