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:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user