1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

windows: use %USERPROFILE% for os.home_dir()

This commit is contained in:
vitalyster 2020-02-18 04:12:10 +03:00 committed by GitHub
parent 2ea2fed8a5
commit 2e1dbd9f5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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`.