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

[SR-11089] Add a "nullDevice" extension to Foundation's FileManager #3995

Closed
swift-ci opened this issue Jul 8, 2019 · 5 comments
Closed

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Jul 8, 2019

Previous ID SR-11089
Radar None
Original Reporter gwenm (JIRA User)
Type New Feature
Status Resolved
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels New Feature
Assignee gwenm (JIRA)
Priority Medium

md5: a5019f0d2556bf17e09a687f42370d94

Issue Description:

Windows and Unix use different spelling of the null device (NUL vs /dev/null). Rather than conveniently accepting /dev/null as an alias to {{NUL}} on Windows, it would make more sense to have an extension to return the proper path as a URL.

@swift-ci
Copy link
Contributor Author

swift-ci commented Jul 8, 2019

Comment by Gwen Mittertreiner (JIRA)

@millenomi Would this be a reasonable thing to add to Foundation?

@millenomi
Copy link
Contributor

FileHandle already provides handles to write to the null device (via its .nullDevice property).

What is your intended use? Note that in the general case we cannot add API surface to swift-corelibs-foundation that doesn’t already exist on Darwin.

@swift-ci
Copy link
Contributor Author

swift-ci commented Jul 9, 2019

Comment by Gwen Mittertreiner (JIRA)

This came up with the contentEqual tests in the form of having to write:

#if os(Windows)
        XCTAssertTrue(fm.contentsEqual(atPath: "NUL", andPath: "NUL"))
#else
        XCTAssertTrue(fm.contentsEqual(atPath: "/dev/null", andPath: "/dev/null"))
#endif

Where it would significantly more portable to expose something like fm.contentsEqual(atPath: fm.nullDevice.path, andPath: fm.nullDevice.path)). However, I could see it used with any sort of api which accepts a string path or url to a file to read or write from. For example, where to log output to or where to read a config file from.

What do you mean by something already existing on Darwin? As it it already exists in the objective-c Foundation?

@millenomi
Copy link
Contributor

Correct. It is not a goal of the project to introduce new API, because it is meant to allow source portability, and code that isn't compilable on Darwin is by definition not portable.

If this is a need in the tests, perhaps the tests should have that as a utility. I don't recall the need being widespread within TestFoundation, though.

@swift-ci
Copy link
Contributor Author

Comment by Gwen Mittertreiner (JIRA)

Alright, I'll keep this as a one off for the test(s) that need it.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants