# breaking: improve std.fs directory handling API · gitcafe/zig

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

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

Visibility: public

Requested revision: 5b1a492012241276a4b7539ca6664234f0629c79

Requested commit: 5b1a492012241276a4b7539ca6664234f0629c79

Commit: 5b1a492012241276a4b7539ca6664234f0629c79

Tree: 1f3d38be4e73ab30d65efc453892c355ef7d3ec4

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
breaking: improve std.fs directory handling API

 * Added `std.c.unlinkat` and `std.os.unlinkat`.
 * Removed `std.fs.MAX_BUF_BYTES` (this declaration never made it to
   master branch)
 * Added `std.fs.Dir.deleteTree` to be used on an open directory handle.
 * `std.fs.deleteTree` has better behavior for both relative and
   absolute paths. For absolute paths, it opens the base directory
   and uses that handle for subsequent operations. For relative paths,
   it does a similar strategy, using the cwd handle.
 * The error set of `std.fs.deleteTree` is improved to no longer have
   these possible errors:
   - OutOfMemory
   - FileTooBig
   - IsDir
   - DirNotEmpty
   - PathAlreadyExists
   - NoSpaceLeft
 * Added `std.fs.Dir.posix_cwd` which is a statically initialized
   directory representing the current working directory.
 * The error set of `std.Dir.open` is improved to no longer have these
   possible errors:
   - FileTooBig
   - IsDir
   - NoSpaceLeft
   - PathAlreadyExists
   - OutOfMemory
 * Added more alternative functions to `std.fs` for when the path
   parameter is a null terminated string. This can sometimes be more
   effecient on systems which have an ABI based on  null terminated
   strings.
 * Added `std.fs.Dir.openDir`, `std.fs.Dir.deleteFile`, and
   `std.fs.Dir.deleteDir` which all operate on an open directory handle.
 * `std.fs.Walker.Entry` now has a `dir` field, which can be used to do
   operations directly on `std.fs.Walker.Entry.basename`, avoiding
   `error.NameTooLong` for deeply nested paths.
 * Added more docs to `std.os.OpenError`

This commit does the POSIX components for these changes. I plan to
follow up shortly with a commit for Windows.

```

## Parents

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

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