elvish/pkg/shell/paths_windows.go
2021-01-27 01:30:25 +00:00

24 lines
478 B
Go

package shell
import (
"fmt"
"os"
"path/filepath"
"src.elv.sh/pkg/env"
)
// getSecureRunDir stats elvish-$USERNAME under the default temp dir, creating
// it if it doesn't yet exist, and return the directory name.
func getSecureRunDir() (string, error) {
username := os.Getenv(env.USERNAME)
runDir := filepath.Join(os.TempDir(), "elvish-"+username)
err := os.MkdirAll(runDir, 0700)
if err != nil {
return "", fmt.Errorf("mkdir: %v", err)
}
return runDir, nil
}