1 ! Copyright (C) 2008 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: alien.strings fry io.encodings.utf16 kernel
4 splitting windows windows.kernel32 windows.types system
5 environment alien.data sequences windows.errors
6 io.streams.memory io.encodings io specialized-arrays ;
7 SPECIALIZED-ARRAY: TCHAR
8 IN: environment.windows
11 MAX_UNICODE_PATH TCHAR <c-array>
12 [ dup length GetEnvironmentVariable ] keep over 0 = [
15 nip alien>native-string
19 swap SetEnvironmentVariable win32-error=0/f ;
21 M: windows unset-os-env
22 f SetEnvironmentVariable 0 = [
23 GetLastError ERROR_ENVVAR_NOT_FOUND =
24 [ win32-error ] unless
28 GetEnvironmentStrings [
31 [ "\0" read-until drop dup empty? not ] [ ] produce nip
33 ] [ FreeEnvironmentStrings win32-error=0/f ] bi ;