From 3a8be4d8d9bed686de32db77df1259b491befaa5 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Wed, 30 Sep 2020 16:02:54 +0200 Subject: [PATCH] os: home_dir() remove trailing slash (#6512) --- cmd/tools/vpm.v | 2 +- vlib/os/os.v | 9 ++++----- vlib/v/pref/default.v | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index 713946b1e3..41b50182c7 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -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) { diff --git a/vlib/os/os.v b/vlib/os/os.v index f3e2c0ec70..402e241d4d 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -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) diff --git a/vlib/v/pref/default.v b/vlib/v/pref/default.v index 82f3f56f23..f4a3428fcb 100644 --- a/vlib/v/pref/default.v +++ b/vlib/v/pref/default.v @@ -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 {