Updated hostname function, also fix previous commit.

Broke read_entire_file_from_handle function in previous commit fix that.
master
Ronald1985 2 years ago
parent d51f2c6e2f
commit 3841b9c4df

@ -52,16 +52,8 @@ __read_entire_file_from_handle :: proc(fd: os.Handle, allocator := context.alloc
bytes_total += bytes_read
resize(&_data, bytes_total + BLOCK_SIZE)
}
return _data[:bytes_total], true
}
get_hostname :: proc() -> (string, bool) {
data, ok := __read_entire_file_from_filename("/proc/sys/kernel/hostname")
hostname: string
hostname, ok = strings.remove_all(string(data), "\n")
return hostname, ok
return _data[:bytes_total], true
}
@(private)
@ -134,6 +126,14 @@ get_ram_usage_perc :: proc() -> (f64, bool) {
return 100 * (((total - free) - (buffers + cached)) / total), true
}
get_hostname :: proc() -> (string, bool) {
data, ok := __read_entire_file_from_filename("/proc/sys/kernel/hostname")
hostname: string
hostname, ok = strings.remove_all(string(data), "\n")
return hostname, ok
}
@(private)
parse_cpuinfo :: proc(cpuinfo: string) -> (map[string]string, bool) {

Loading…
Cancel
Save