Skip to content

Implement file_handle for auto-closing an open file#209

Merged
bugdea1er merged 6 commits into
mainfrom
raii-open-file
May 6, 2025
Merged

Implement file_handle for auto-closing an open file#209
bugdea1er merged 6 commits into
mainfrom
raii-open-file

Conversation

@bugdea1er
Copy link
Copy Markdown
Owner

Eliminate the need to close the file manually in file::copy

@bugdea1er bugdea1er requested a review from Copilot May 4, 2025 19:00

This comment was marked as off-topic.

@bugdea1er bugdea1er requested a review from Copilot May 6, 2025 08:18
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 introduces a RAII wrapper class, file_handle, to manage the lifetime of native file descriptors so that files are automatically closed without manual intervention in file::copy.

  • Introduces file_handle with constructor, conversion operator, and destructor for auto-closing file handles
  • Replaces manual file closing calls in file::copy with the RAII mechanism

Comment thread src/file.cpp Outdated
@bugdea1er bugdea1er merged commit 0831eed into main May 6, 2025
16 checks passed
@bugdea1er bugdea1er deleted the raii-open-file branch May 6, 2025 08:26
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