Skip to content

Implement FileHandle.nullDevice #690

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

Merged
merged 2 commits into from
Nov 10, 2016

Conversation

kareman
Copy link
Contributor

@kareman kareman commented Oct 18, 2016

Not sure if the unit test is needed. I may be testing OS functionality instead of Foundation.



internal static var _nulldeviceFileHandle: FileHandle = {
return FileHandle(forUpdatingAtPath: "/dev/null")!
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the portability story around /dev/null?

For what it's worth, the Darwin Foundation implementation here is a simple subclass of FileHandle that returns empty Data and values of 0 (except for file handle, which is -1).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. This has been tested and works on Ubuntu 15.10 and macOS. I have not been able to confirm that we have access to /dev/null on Android.

In any case a nullDevice subclass would be more efficient. I'll be away for a week but I can try implementing one when I get back.

@kareman
Copy link
Contributor Author

kareman commented Oct 25, 2016

@parkera this should be more like the Darwin implementation.

@kareman
Copy link
Contributor Author

kareman commented Nov 10, 2016

Any news on this?

@parkera
Copy link
Contributor

parkera commented Nov 10, 2016

Oh, sorry! This looks good to me.

@parkera
Copy link
Contributor

parkera commented Nov 10, 2016

@swift-ci please test and merge

@swift-ci swift-ci merged commit 1db5065 into swiftlang:master Nov 10, 2016
@kareman kareman deleted the implement-FileHandle.nullDevice branch December 21, 2016 21:16
@naithar naithar mentioned this pull request Jan 20, 2017
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.

3 participants