mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
22 lines
455 B
Go
22 lines
455 B
Go
package runtime
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// 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("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
|
|
}
|