mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Remove RandomTmpDirPath
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
@@ -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 /
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user