os: home_dir() remove trailing slash (#6512)

pull/6517/head
Lukas Neubert 2020-09-30 16:02:54 +02:00 committed by GitHub
parent 76e373a5f4
commit 3a8be4d8d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 7 deletions

View File

@ -533,7 +533,7 @@ fn init_settings() {
s.is_help = '-h' in os.args || '--help' in os.args || 'help' in os.args
s.is_verbose = '-v' in os.args
s.server_urls = cmdline.options(os.args, '-server-url')
s.vmodules_path = os.home_dir() + '.vmodules'
s.vmodules_path = os.join_path(os.home_dir(), '.vmodules')
}
fn verbose_println(s string) {

View File

@ -651,7 +651,6 @@ pub fn dir(path string) string {
}
// base_dir will return the base directory of `path`.
// The `path_separator` is included.
pub fn base_dir(path string) string {
posx := path.last_index(path_separator) or {
return path.clone()
@ -824,12 +823,12 @@ pub fn user_os() string {
// home_dir returns path to user's home directory.
pub fn home_dir() string {
$if windows {
return os.getenv('USERPROFILE') + os.path_separator
return os.getenv('USERPROFILE')
} $else {
//println('home_dir() call')
//res:= os.getenv('HOME') + os.path_separator
//res:= os.getenv('HOME')
//println('res="$res"')
return os.getenv('HOME') + os.path_separator
return os.getenv('HOME')
}
}
@ -1275,7 +1274,7 @@ pub fn cache_dir() string {
return xdg_cache_home
}
}
cdir := os.home_dir() + '.cache'
cdir := os.join_path(os.home_dir(), '.cache')
if !os.is_dir(cdir) && !os.is_link(cdir) {
os.mkdir(cdir) or {
panic(err)

View File

@ -10,7 +10,7 @@ pub const (
)
fn mpath() string {
return os.home_dir() + '.vmodules'
return os.join_path(os.home_dir(), '.vmodules')
}
pub fn new_preferences() Preferences {