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

Add 'withTemporaryDirectory' #2708

Merged
merged 3 commits into from
Apr 26, 2024
Merged

Add 'withTemporaryDirectory' #2708

merged 3 commits into from
Apr 26, 2024

Conversation

glbrntt
Copy link
Contributor

@glbrntt glbrntt commented Apr 26, 2024

Motivation:

NIOFileSystem can create the path of a temporary directory but doesn't offer any API to create and then remove a directory.

Modifications:

  • Add withTemporaryDirectory

Result:

Motivation:

NIOFileSystem can create the path of a temporary directory but doesn't
offer any API to create and then remove a directory.

Modifications:

- Add `withTemporaryDirectory`

Result:

- Users can get scoped access to a temporary directory which is
  subsequently removed for them
- Resolves apple#2664
@glbrntt glbrntt added the 🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0 label Apr 26, 2024
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Generally good, a quick note on generic type parameters if you want to take it.

/// - options: Options used to create the directory.
/// - execute: A closure which provides access to the directory and its path.
/// - Returns: The result of `execute`.
public func withTemporaryDirectory<R>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer longer type variable names. ReturnType is usually better than R.

@glbrntt glbrntt enabled auto-merge (squash) April 26, 2024 08:02
@glbrntt glbrntt merged commit 8c3135b into apple:main Apr 26, 2024
8 of 9 checks passed
@glbrntt glbrntt deleted the with-temp-dir branch April 26, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NIOFileSystem: Should offer withTemporaryDirectory
2 participants