windows: use %USERPROFILE% for os.home_dir()
parent
2ea2fed8a5
commit
2e1dbd9f5a
15
vlib/os/os.v
15
vlib/os/os.v
|
@ -785,20 +785,11 @@ pub fn user_os() string {
|
||||||
|
|
||||||
// home_dir returns path to user's home directory.
|
// home_dir returns path to user's home directory.
|
||||||
pub fn home_dir() string {
|
pub fn home_dir() string {
|
||||||
mut home := os.getenv('HOME')
|
|
||||||
$if windows {
|
$if windows {
|
||||||
home = os.getenv('HOMEDRIVE')
|
return os.getenv('USERPROFILE') + filepath.separator
|
||||||
if home.len == 0 {
|
} $else {
|
||||||
home = os.getenv('SYSTEMDRIVE')
|
return os.getenv('HOME') + filepath.separator
|
||||||
}
|
}
|
||||||
mut homepath := os.getenv('HOMEPATH')
|
|
||||||
if homepath.len == 0 {
|
|
||||||
homepath = '\\Users\\' + os.getenv('USERNAME')
|
|
||||||
}
|
|
||||||
home += homepath
|
|
||||||
}
|
|
||||||
home += filepath.separator
|
|
||||||
return home
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// write_file writes `text` data to a file in `path`.
|
// write_file writes `text` data to a file in `path`.
|
||||||
|
|
Loading…
Reference in New Issue