Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce std.fs.Dir.openFile and std.fs.Dir.createFile #3813

Merged
merged 3 commits into from Nov 30, 2019
Merged

Conversation

andrewrk
Copy link
Member

These functions have flags parameters which cover all the use cases. The other functions are now deprecated.

std.fs.openFileAbsolute and related functions are also added. It should now be clear the pattern that the standard library file system API is approaching. The API encourages programmers to take advantage of directory traversal via directory handles, for better general protection against Time Of Check, Time Of Use bugs across all Zig codebases.

This PR also moves std.fs.Dir.cwd to std.fs.cwd, which is a breaking change. Other functions remain deprecated, to be removed with #3811.

These functions have flags parameters which cover all the use cases. The
other functions are now deprecated.
update to non-deprecated std.fs APIs throughout the codebase

Related: #3811
@andrewrk andrewrk added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. labels Nov 30, 2019
return File{ .handle = fd };
}

/// Same as `createFile` but the path parameter is WTF-16 encoded.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not entirely the same, as it doesn't support non-windows.

Also the encoding is UCS-2. WTF-16 isn't a thing (though WTF-8 is)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a reference to https://simonsapin.github.io/wtf-8/#wtf-16. I think this is different than UCS-2

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll further improve the docs it to make it clear though 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants