2014-08-05 20:43:33 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2014-11-13 18:48:19 +00:00
|
|
|
"path/filepath"
|
2014-08-05 20:43:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// TempDir returns the default directory to use for temporary files.
|
2014-11-13 18:48:19 +00:00
|
|
|
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
|
2014-08-05 20:43:33 +00:00
|
|
|
}
|