diff options
| author | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
| commit | 404aeae4545d2426c089a5f8d5e82dae56f5212b (patch) | |
| tree | 2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/golang.org/x/sys/windows/env_windows.go | |
| parent | 209d8b0187ed025dec9ac149ebcced3462877bff (diff) | |
| download | gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip | |
Make Nix builds work
Diffstat (limited to 'vendor/golang.org/x/sys/windows/env_windows.go')
| -rw-r--r-- | vendor/golang.org/x/sys/windows/env_windows.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/windows/env_windows.go b/vendor/golang.org/x/sys/windows/env_windows.go new file mode 100644 index 0000000..b8ad192 --- /dev/null +++ b/vendor/golang.org/x/sys/windows/env_windows.go | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | // Copyright 2010 The Go Authors. All rights reserved. | ||
| 2 | // Use of this source code is governed by a BSD-style | ||
| 3 | // license that can be found in the LICENSE file. | ||
| 4 | |||
| 5 | // Windows environment variables. | ||
| 6 | |||
| 7 | package windows | ||
| 8 | |||
| 9 | import ( | ||
| 10 | "syscall" | ||
| 11 | "unsafe" | ||
| 12 | ) | ||
| 13 | |||
| 14 | func Getenv(key string) (value string, found bool) { | ||
| 15 | return syscall.Getenv(key) | ||
| 16 | } | ||
| 17 | |||
| 18 | func Setenv(key, value string) error { | ||
| 19 | return syscall.Setenv(key, value) | ||
| 20 | } | ||
| 21 | |||
| 22 | func Clearenv() { | ||
| 23 | syscall.Clearenv() | ||
| 24 | } | ||
| 25 | |||
| 26 | func Environ() []string { | ||
| 27 | return syscall.Environ() | ||
| 28 | } | ||
| 29 | |||
| 30 | // Returns a default environment associated with the token, rather than the current | ||
| 31 | // process. If inheritExisting is true, then this environment also inherits the | ||
| 32 | // environment of the current process. | ||
| 33 | func (token Token) Environ(inheritExisting bool) (env []string, err error) { | ||
| 34 | var block *uint16 | ||
| 35 | err = CreateEnvironmentBlock(&block, token, inheritExisting) | ||
| 36 | if err != nil { | ||
| 37 | return nil, err | ||
| 38 | } | ||
| 39 | defer DestroyEnvironmentBlock(block) | ||
| 40 | blockp := unsafe.Pointer(block) | ||
| 41 | for { | ||
| 42 | entry := UTF16PtrToString((*uint16)(blockp)) | ||
| 43 | if len(entry) == 0 { | ||
| 44 | break | ||
| 45 | } | ||
| 46 | env = append(env, entry) | ||
| 47 | blockp = unsafe.Add(blockp, 2*(len(entry)+1)) | ||
| 48 | } | ||
| 49 | return env, nil | ||
| 50 | } | ||
| 51 | |||
| 52 | func Unsetenv(key string) error { | ||
| 53 | return syscall.Unsetenv(key) | ||
| 54 | } | ||