|
@@ -7,6 +7,7 @@ import "base:runtime"
|
|
// If the variable is found in the environment the value (which can be empty) is returned and the boolean is true
|
|
// If the variable is found in the environment the value (which can be empty) is returned and the boolean is true
|
|
// Otherwise the returned value will be empty and the boolean will be false
|
|
// Otherwise the returned value will be empty and the boolean will be false
|
|
// NOTE: the value will be allocated with the supplied allocator
|
|
// NOTE: the value will be allocated with the supplied allocator
|
|
|
|
+@(require_results)
|
|
lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) {
|
|
lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) {
|
|
if key == "" {
|
|
if key == "" {
|
|
return
|
|
return
|
|
@@ -33,6 +34,7 @@ lookup_env :: proc(key: string, allocator := context.allocator) -> (value: strin
|
|
// It returns the value, which will be empty if the variable is not present
|
|
// It returns the value, which will be empty if the variable is not present
|
|
// To distinguish between an empty value and an unset value, use lookup_env
|
|
// To distinguish between an empty value and an unset value, use lookup_env
|
|
// NOTE: the value will be allocated with the supplied allocator
|
|
// NOTE: the value will be allocated with the supplied allocator
|
|
|
|
+@(require_results)
|
|
get_env :: proc(key: string, allocator := context.allocator) -> (value: string) {
|
|
get_env :: proc(key: string, allocator := context.allocator) -> (value: string) {
|
|
value, _ = lookup_env(key, allocator)
|
|
value, _ = lookup_env(key, allocator)
|
|
return
|
|
return
|
|
@@ -60,6 +62,7 @@ unset_env :: proc(key: string) -> Errno {
|
|
|
|
|
|
// environ returns a copy of strings representing the environment, in the form "key=value"
|
|
// environ returns a copy of strings representing the environment, in the form "key=value"
|
|
// NOTE: the slice of strings and the strings with be allocated using the supplied allocator
|
|
// NOTE: the slice of strings and the strings with be allocated using the supplied allocator
|
|
|
|
+@(require_results)
|
|
environ :: proc(allocator := context.allocator) -> []string {
|
|
environ :: proc(allocator := context.allocator) -> []string {
|
|
envs := ([^]win32.WCHAR)(win32.GetEnvironmentStringsW())
|
|
envs := ([^]win32.WCHAR)(win32.GetEnvironmentStringsW())
|
|
if envs == nil {
|
|
if envs == nil {
|