launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/juju/osenv/vars_windows.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package osenv
     5  
     6  import (
     7  	"os"
     8  	"path"
     9  	"path/filepath"
    10  )
    11  
    12  // Home returns the os-specific home path as specified in the environment
    13  func Home() string {
    14  	return path.Join(os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH"))
    15  }
    16  
    17  // SetHome sets the os-specific home path in the environment
    18  func SetHome(s string) error {
    19  	v := filepath.VolumeName(s)
    20  	if v != "" {
    21  		if err := os.Setenv("HOMEDRIVE", v); err != nil {
    22  			return err
    23  		}
    24  	}
    25  	return os.Setenv("HOMEPATH", s[len(v):])
    26  }