Skip to content

Parity: FileManager.replaceItem(…) #2311

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 1 commit into from
May 31, 2019
Merged

Parity: FileManager.replaceItem(…) #2311

merged 1 commit into from
May 31, 2019

Conversation

millenomi
Copy link
Contributor

  • Instead of returning nothing from .url(for: .itemReplacementDirectory…), produce a path the same way Darwin does.

  • Implement replaceItems(…) for POSIX-y platforms. We try to use Darwin and Linux swap syscalls to ensure race-free atomicity if available, and if these fail we fall back to an implementation that has different degrees of atomicity depending on what object is replaced with what object.

  • Add tests.

@millenomi
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor Author

I need a wrapper for renameat2, I assume.

 - Instead of returning nothing from .url(for: .itemReplacementDirectory…), produce a path the same way Darwin does.

 - Implement replaceItems(…) for POSIX-y platforms. We try to use Darwin and Linux swap syscalls to ensure race-free atomicity if available, and if these fail we fall back to an implementation that has different degrees of atomicity depending on what object is replaced with what object.

 - Add tests.
@millenomi
Copy link
Contributor Author

@swift-ci please test and merge

1 similar comment
@millenomi
Copy link
Contributor Author

@swift-ci please test and merge

@swift-ci swift-ci merged commit 75fa8e0 into swiftlang:master May 31, 2019
@spevans
Copy link
Contributor

spevans commented Jun 26, 2019

@pschuh A #ifdef SYS_renameat2 was added in https://github.com/apple/swift-corelibs-foundation/pull/2337/files#diff-33ef000612768310a8c08cd83b00f95fR598 which should stop the syscall being compiled if it is not defined. There is also a runtime check of the kernel version to check the sys call is actually available. What error are you seeing

@pschuh
Copy link

pschuh commented Jun 26, 2019

Sounds good! I just need to wait for the update-checkout to get up to that version then.

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.

4 participants