# WASI: remove absolute path emulation from std lib · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/d5312d53a066092ba9efd687e25b29a87eb6290c)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: d5312d53a066092ba9efd687e25b29a87eb6290c

Requested commit: d5312d53a066092ba9efd687e25b29a87eb6290c

Commit: d5312d53a066092ba9efd687e25b29a87eb6290c

Tree: b94a89b89f333cf381046982afe6a86c72c8122e

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
WASI: remove absolute path emulation from std lib

Instead of checking for absolute paths and current working directories
in various file system operations, there is one simple solution: allow
overriding `std.fs.cwd` on WASI.

os.realpath is back to causing a compile error when used on WASI. This
caused a compile error in the Sema handling of `@src()`. The compiler
should never call realpath, so the commit that made this change is
reverted (95ab942184427e7c9b840d71f4d093931e3e48fb). If this breaks
debug info, a different strategy is needed to solve it other than using
realpath.

I also removed the preopens code and replaced it with something much
simpler. There is no longer any global state in the standard library.

Additionally-
 * os.openat no longer does an unnecessary fstat on WASI when O.WRONLY
   is not provided.
 * os.chdir is back to causing a compile error on WASI.

```

## Parents

- [0a2fdfbdb934faae7fcf63e9b3ab760c00f47918](https://git.cafe/gitcafe/zig/commit/0a2fdfbdb934faae7fcf63e9b3ab760c00f47918?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/d5312d53a066092ba9efd687e25b29a87eb6290c?format=markdown)
