Known folders can be redirected using `SHSetKnownFolderPath`, and it's a bit iffy to rely on environment variables.
This also more easily allows us to add `user_*_dir` procedures for the remaining 139 GUIDs in `known_folders.odin`, provided they have equivalents on other platforms.
The _set_env procedure in core/os/os2/env_posix.odin was
incorrectly cloning the 'key' argument for 'cval' instead of
the 'value' argument. This resulted in set_env effectively
setting the environment variable's value to its own key.
This commit corrects the typo to use the 'value' argument.
There are several places where this is assumed to be true, most visibly
in `is_path_separator`, as it takes a `byte` argument.
Note that the data type of `_Path_Separator` is a rune, which allows any
Unicode value.
Switched to a recursive mutex so that procedures which need to perform
lookups can do so while also maintaining the lock across their entire
body in order to guarantee atomicity for each environment operation.
This removes the data race caused by multiple threads using the
unprotected global `random_string_seed`, so long as no two threads share
the same random generator; this is the default case.
Additionally, `os2.random_string` now takes into account the full buffer
slice given to it.
`strings.to_cstring` previously would not check if the buffer could
handle the extra null byte and could lead to segmentation violations
when using the resulting string in an API expecting the terminator.
Adds a directory walker, a method of exposing and retrieving errors from
the existing read directory iterator, allows reusing of the existing
read directory iterator, and adds a file clone procedure