Add cross-platform file I/O utilities - #660
Draft
Conrad Johnston (ConradJohnston) wants to merge 26 commits into
Draft
Add cross-platform file I/O utilities#660Conrad Johnston (ConradJohnston) wants to merge 26 commits into
Conrad Johnston (ConradJohnston) wants to merge 26 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> # Conflicts: # cpp/src/qdk/chemistry/utils/CMakeLists.txt # python/src/qdk_chemistry/utils/__init__.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Conrad Johnston (ConradJohnston)
August 25, 2026 19:08
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds shared C++ and Python file I/O utilities as the first step toward #655.
Changes:
- Adds atomic file replacement, text reading, and parent-directory helpers.
- Handles permissions, Unicode paths, Windows read-only files, and cleanup.
- Adds extensive cross-platform regression tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
cpp/include/qdk/chemistry/utils/file_io.hpp |
Declares the C++ API. |
cpp/src/qdk/chemistry/utils/file_io.cpp |
Implements C++ file operations. |
cpp/src/qdk/chemistry/utils/CMakeLists.txt |
Adds the implementation to the library. |
cpp/tests/test_file_io.cpp |
Adds C++ regression tests. |
python/src/qdk_chemistry/utils/file_io.py |
Implements Python file operations. |
python/src/qdk_chemistry/utils/__init__.py |
Exports the Python API. |
python/tests/test_utils_file_io.py |
Adds Python regression tests. |
Suppressed comments (2)
cpp/tests/test_file_io.cpp:44
- Several Windows tests intentionally leave files with
FILE_ATTRIBUTE_READONLY, which causesstd::filesystem::remove_allto fail. Ignoring that error leaks the per-test directory and masks cleanup regressions. Clear read-only attributes during teardown and report a failure if the final removal fails.
void TearDown() override {
std::error_code ignored;
std::filesystem::remove_all(root_, ignored);
cpp/tests/test_file_io.cpp:612
- This expectation is not valid on Windows. The reserved handle remains open after
remove, so the file is delete-pending and theofstreamcannot recreate the same pathname; after the reservation closes, no replacement remains. The Python counterpart explicitly skips this assertion on Windows. Guard this assertion likewise, or assert the platform-specific outcome.
EXPECT_TRUE(std::filesystem::exists(replacement_path));
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+35
to
+39
| root_ = std::filesystem::temp_directory_path() / | ||
| ("qdk_file_io_test_" + | ||
| std::to_string( | ||
| std::chrono::steady_clock::now().time_since_epoch().count())); | ||
| std::filesystem::create_directories(root_); |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
First step toward #655.