# fix std.fs.Dir.makePath silent failure \(\#16878\) · gitcafe/zig

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

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

Visibility: public

Requested revision: 4cbf74bd9b839501a4fd4bc5f39a25e216237b3c

Requested commit: 4cbf74bd9b839501a4fd4bc5f39a25e216237b3c

Commit: 4cbf74bd9b839501a4fd4bc5f39a25e216237b3c

Tree: 6cc25456391073e1820167cf896c2cf710dd18dc

Author: Amir Alawi

Committer: GitHub

## Message

```
fix std.fs.Dir.makePath silent failure (#16878)

std.fs.dir.makePath silently failed if one of the items in the path already exists. For example:

cwd.makePath("foo/bar/baz")
Silently failing is OK if "bar" is already a directory - this is the intended use of makePath (like mkdir -p). But if bar is a file then the subdirectory baz cannot be created - the end result is that makePath doesn't do anything which should be a detectable error because baz is never created.

The existing code had a TODO comment that did not specifically cover this error, but the solution for this silent failure also accomplishes the TODO task - the code now stats "foo" and returns an appropriate error. The new code also handles potential race condition if "bar" is deleted/permissions changed/etc in between the initial makeDir and statFile calls.
```

## Parents

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

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