Skip to content

Conversation

@squeek502
Copy link
Member

@squeek502 squeek502 commented Oct 14, 2022

Before this PR, the added test would have failed on Windows with the error found in #8268.

Fixes #8268.

@squeek502 squeek502 changed the title Windows: Fix iterator name buffer size not handling all possible file name components Windows: Fix Iterator name buffer size not handling all possible file name components Oct 14, 2022
Copy link
Contributor

@matu3ba matu3ba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments should be more conservative regarding guarantees, because the limits "generally work", but not in all cases (configuartions etc).
For general, portable + robust solutions, one must know the target systems limits and/or query the OS Kernel.

Please correct me, where I am wrong and which Kernels provide hard guarantees.

Also add some NAME_MAX or equivalent definitions where necessary
… name components

Each u16 within a file name component can be encoded as up to 3 UTF-8 bytes, so we need to use MAX_NAME_BYTES to account for all possible UTF-8 encoded names.

Fixes ziglang#8268
…orms

This is a slightly weird situation, because the 'real' value may depend on the host platform that the WASI is being executed on.
Make the test use the minimum length and set MAX_NAME_BYTES to the maximum so that:
- the test will work on any host platform
- *and* the MAX_NAME_BYTES will be able to hold the max file name component on any host platform
@squeek502 squeek502 force-pushed the iterator-filename-limits branch from 4da34d5 to db80225 Compare October 29, 2022 21:31
@andrewrk andrewrk merged commit 209a0d2 into ziglang:master Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std.fs.Dir.Iterator cannot handle long file names on Windows

4 participants