github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/pkg/shell/paths_windows.go (about)

     1  package shell
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"path/filepath"
     7  
     8  	"src.elv.sh/pkg/env"
     9  )
    10  
    11  // getSecureRunDir stats elvish-$USERNAME under the default temp dir, creating
    12  // it if it doesn't yet exist, and return the directory name.
    13  func getSecureRunDir() (string, error) {
    14  	username := os.Getenv(env.USERNAME)
    15  
    16  	runDir := filepath.Join(os.TempDir(), "elvish-"+username)
    17  	err := os.MkdirAll(runDir, 0700)
    18  	if err != nil {
    19  		return "", fmt.Errorf("mkdir: %v", err)
    20  	}
    21  
    22  	return runDir, nil
    23  }