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

os: create os.hostname() and os.chown() + os.uname() for windows (#9722)

This commit is contained in:
Bastian Buck
2021-04-15 01:49:05 +02:00
committed by GitHub
parent 25a9d30a70
commit 546dc91967
3 changed files with 48 additions and 8 deletions

View File

@@ -51,6 +51,8 @@ fn C.uname(name voidptr) int
fn C.symlink(&char, &char) int
fn C.gethostname(&char, int) int
pub fn uname() Uname {
mut u := Uname{}
utsize := sizeof(C.utsname)
@@ -69,6 +71,18 @@ pub fn uname() Uname {
return u
}
pub fn hostname() string {
mut hstnme := ''
size := 256
mut buf := unsafe { &char(malloc(size)) }
if C.gethostname(buf, size) == 0 {
hstnme = unsafe { cstring_to_vstring(buf) }
unsafe { free(buf) }
return hstnme
}
return ''
}
fn init_os_args(argc int, argv &&byte) []string {
mut args_ := []string{}
// mut args := []string(make(0, argc, sizeof(string)))