Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: clarify some doc comments #21209

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions vlib/os/os.v
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub fn get_raw_lines_joined() string {
return res
}

// user_os returns current user operating system name.
// user_os returns the current user's operating system name.
pub fn user_os() string {
$if linux {
return 'linux'
Expand Down Expand Up @@ -443,7 +443,7 @@ pub fn user_os() string {
return 'unknown'
}

// user_names returns an array of the name of every user on the system.
// user_names returns an array containing the names of all users on the system.
pub fn user_names() ![]string {
$if windows {
result := execute('wmic useraccount get name')
Expand All @@ -465,7 +465,7 @@ pub fn user_names() ![]string {
}
}

// home_dir returns path to the user's home directory.
// home_dir returns the path to the current user's home directory.
pub fn home_dir() string {
$if windows {
return getenv('USERPROFILE')
Expand All @@ -490,8 +490,8 @@ pub fn expand_tilde_to_home(path string) string {
return path
}

// write_file writes `text` data to the file in `path`.
// If `path` exists, the contents of `path` will be overwritten with the contents of `text`.
// write_file writes `text` data to a file with the given `path`.
// If `path` already exists, it will be overwritten.
pub fn write_file(path string, text string) ! {
mut f := create(path)!
unsafe { f.write_full_buffer(text.str, usize(text.len))! }
Expand All @@ -510,15 +510,15 @@ fn error_failed_to_find_executable() IError {
return &ExecutableNotFoundError{}
}

// find_abs_path_of_executable walks the environment PATH, just like most shell do, it returns
// the absolute path of the executable if found
pub fn find_abs_path_of_executable(exepath string) !string {
if exepath == '' {
return error('expected non empty `exepath`')
// find_abs_path_of_executable searches the environment PATH for the
// absolute path of the given executable name.
pub fn find_abs_path_of_executable(exe_name string) !string {
if exe_name == '' {
return error('expected non empty `exe_name`')
}

for suffix in executable_suffixes {
fexepath := exepath + suffix
fexepath := exe_name + suffix
if is_abs_path(fexepath) {
return real_path(fexepath)
}
Expand Down