浏览代码

Consolidate tmpdir implementations, include Windows

Signed-off-by: Ahmet Alp Balkan <ahmetb@microsoft.com>
Ahmet Alp Balkan 10 年之前
父节点
当前提交
376ae7780b
共有 2 个文件被更改,包括 8 次插入22 次删除
  1. 8 4
      utils/tmpdir.go
  2. 0 18
      utils/tmpdir_unix.go

+ 8 - 4
utils/tmpdir.go

@@ -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) {
-	return os.TempDir(), nil
+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
 }
 }

+ 0 - 18
utils/tmpdir_unix.go

@@ -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
-}