`setenv` and `unsetenv` for windows fix
parent
f5fa43d2fa
commit
e638e47af5
|
@ -106,7 +106,6 @@ fn parse_windows_cmd_line(cmd byteptr) []string {
|
|||
}
|
||||
|
||||
// read_file reads the file in `path` and returns the contents.
|
||||
//pub fn read_file(path string) ?string {
|
||||
pub fn read_file(path string) ?string {
|
||||
mut res := ''
|
||||
mut mode := 'rb'
|
||||
|
@ -294,7 +293,13 @@ pub fn getenv(key string) string {
|
|||
|
||||
pub fn setenv(name string, value string, overwrite bool) int {
|
||||
$if windows {
|
||||
format := '$name=$value'
|
||||
|
||||
if overwrite {
|
||||
return C._putenv(format.cstr())
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
$else {
|
||||
return C.setenv(name.cstr(), value.cstr(), overwrite)
|
||||
|
@ -303,7 +308,9 @@ $else {
|
|||
|
||||
pub fn unsetenv(name string) int {
|
||||
$if windows {
|
||||
format := '${name}='
|
||||
|
||||
return C._putenv(format.cstr())
|
||||
}
|
||||
$else {
|
||||
return C.unsetenv(name.cstr())
|
||||
|
|
Loading…
Reference in New Issue