mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Consolidate tmpdir implementations, include Windows
Signed-off-by: Ahmet Alp Balkan <ahmetb@microsoft.com>
This commit is contained in:
parent
91a86670aa
commit
376ae7780b
2 changed files with 8 additions and 22 deletions
|
@ -1,12 +1,16 @@
|
||||||
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
|
|
||||||
|
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TempDir returns the default directory to use for temporary files.
|
// TempDir returns the default directory to use for temporary files.
|
||||||
func TempDir(rootdir string) (string error) {
|
func TempDir(rootDir string) (string, error) {
|
||||||
return os.TempDir(), nil
|
var tmpDir string
|
||||||
|
if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
|
||||||
|
tmpDir = filepath.Join(rootDir, "tmp")
|
||||||
|
}
|
||||||
|
err := os.MkdirAll(tmpDir, 0700)
|
||||||
|
return tmpDir, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
|
||||||
|
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TempDir returns the default directory to use for temporary files.
|
|
||||||
func TempDir(rootDir string) (string, error) {
|
|
||||||
var tmpDir string
|
|
||||||
if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
|
|
||||||
tmpDir = filepath.Join(rootDir, "tmp")
|
|
||||||
}
|
|
||||||
err := os.MkdirAll(tmpDir, 0700)
|
|
||||||
return tmpDir, err
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue