Refactor create_file for posix#199
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the create_file function for POSIX environments by removing the error-code–returning overload and inlining temporary-file creation logic in the default overload. Key changes include:
- Removal of the create_file(std::error_code&) overload.
- Inlining the logic to first try O_TMPFILE and fallback to mkstemp, storing errno before unlinking.
- Throwing a fs::filesystem_error on failure instead of returning an error code.
Comments suppressed due to low confidence (1)
src/create.cpp:202
- [nitpick] Consider renaming 'create_error' to something like 'mkstemp_errno' to better convey that it captures the errno value post mkstemp.
int create_error = errno;
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the temporary file creation logic on POSIX systems by removing the error_code–based overload and introducing exception–based error handling.
- Removed the legacy create_file(std::error_code&) overload
- Updated the create_file() function to use exception throwing on file creation failure
- Simplified and centralized the temporary file creation flow using O_TMPFILE and mkstemp
Comments suppressed due to low confidence (2)
src/create.cpp:154
- [nitpick] The removal of the error_code-based overload changes the error handling behavior. Please verify that all call sites have been updated to handle exceptions instead of error codes.
#else
src/create.cpp:202
- [nitpick] Since this branch now throws an exception on mkstemp failure, make sure that the exception handling is consistent with the rest of the project and that callers are prepared for this behavior shift.
if (handle == -1) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove the
create_file(std::error_code&)overload