# std.fs.rename: fix Windows implementation · gitcafe/zig

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

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

Visibility: public

Requested revision: d3f87f8ac01039722197a13a12342fc747a90567

Requested commit: d3f87f8ac01039722197a13a12342fc747a90567

Commit: d3f87f8ac01039722197a13a12342fc747a90567

Tree: 226dfc7c6e61533b34a083f810b3e1429390e679

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std.fs.rename: fix Windows implementation

The semantics of this function are that it moves both files and
directories. Previously we had this `is_dir` boolean field of
`std.os.windows.OpenFile` which required the API user to choose: are we
opening a file or directory? And the other kind would either cause
error.IsDir or error.NotDir. But that is not a limitation of the Windows
file system API; it was self-imposed.

On Windows, rename is implemented internally with `NtCreateFile` so we
need to allow it to open either files or directories. This is now done
by `std.os.windows.OpenFile` accepting enum{file_only,dir_only,any}
instead of a boolean.

```

## Parents

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

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