Remove RandomTmpDirPath

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin
2017-08-22 16:08:42 -04:00
parent e8bd671815
commit 9db68f4dea
7 changed files with 27 additions and 48 deletions

View File

@@ -1,10 +1,13 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/docker/docker/pkg/stringutils"
"github.com/docker/docker/pkg/testutil/cmd"
)
@@ -46,3 +49,18 @@ func ParseCgroupPaths(procCgroupData string) map[string]string {
}
return cgroupPaths
}
// RandomTmpDirPath provides a temporary path with rand string appended.
// does not create or checks if it exists.
func RandomTmpDirPath(s string, platform string) string {
// TODO: why doesn't this use os.TempDir() ?
tmp := "/tmp"
if platform == "windows" {
tmp = os.Getenv("TEMP")
}
path := filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
if platform == "windows" {
return filepath.FromSlash(path) // Using \
}
return filepath.ToSlash(path) // Using /
}