Skip to content

Refactor create_file#217

Merged
bugdea1er merged 4 commits into
mainfrom
create_file
Jun 5, 2025
Merged

Refactor create_file#217
bugdea1er merged 4 commits into
mainfrom
create_file

Conversation

@bugdea1er
Copy link
Copy Markdown
Owner

Move out the common code

@bugdea1er bugdea1er requested a review from Copilot June 5, 2025 18:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the temporary file creation logic by extracting the file reopening functionality into a separate function, aiming to reduce duplicate code.

  • Introduces a new function, reopen_file, for reopening temporary files.
  • Updates create_file to use the new reopen_file function and improved error handling.
Comments suppressed due to low confidence (2)

src/file.cpp:102

  • Undefined variable 'mode' used in _wfreopen; consider replacing it with the passed in 'mdstring' to correctly specify the file open mode.
file = _wfreopen(path.c_str(), make_mdstring(mode), file);

src/file.cpp:85

  • The file pointer is passed by value to reopen_file, so reassigning it inside the function will not update the caller's variable. Consider passing it by reference (std::FILE*&) or returning the updated file pointer.
void reopen_file(const fs::path::value_type* mdstring, std::FILE* file, std::error_code& ec) noexcept {

@bugdea1er bugdea1er merged commit 9141e70 into main Jun 5, 2025
16 checks passed
@bugdea1er bugdea1er deleted the create_file branch June 5, 2025 20:23
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.

2 participants