github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/util/configv3/home_dir_windows.go (about)

     1  // +build windows
     2  
     3  package configv3
     4  
     5  import (
     6  	"os"
     7  	"path/filepath"
     8  )
     9  
    10  func ConfigFilePath() string {
    11  	return filepath.Join(homeDirectory(), ".cf", "config.json")
    12  }
    13  
    14  // See: http://stackoverflow.com/questions/7922270/obtain-users-home-directory
    15  // we can't cross compile using cgo and use user.Current()
    16  func homeDirectory() string {
    17  	var homeDir string
    18  	switch {
    19  	case os.Getenv("CF_HOME") != "":
    20  		homeDir = os.Getenv("CF_HOME")
    21  	case os.Getenv("HOMEDRIVE")+os.Getenv("HOMEPATH") != "":
    22  		homeDir = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
    23  	default:
    24  		homeDir = os.Getenv("USERPROFILE")
    25  	}
    26  	return homeDir
    27  }