host_env: os.mkdir for Windows, Redox by joshuamegnauth54 · Pull Request #8128 · RustPython/RustPython
Important
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 8b226088-7376-4e9b-a250-dd5055e902fe
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
- 🔍 Trigger review
📝 Walkthrough
Walkthrough
The PR unifies the directory-creation API in host_env: the separate make_dir(&CStr, mode) and make_dir_at(i32, &CStr, mode) functions are replaced by a single make_dir(Option<crt_fd::Borrowed<'_>>, &Path, mode) in both posix.rs and posix_wasi.rs, with rustix::fs::mkdirat as the backend. The os stdlib mkdir implementation and platform capability flags are updated to use the new signature.
Changes
Unified make_dir API refactor
| Layer / File(s) | Summary |
|---|---|
New make_dir signature in posix.rs and posix_wasi.rs crates/host_env/src/posix.rs, crates/host_env/src/posix_wasi.rs |
Adds use crate::crt_fd import; replaces old make_dir(&CStr)/make_dir_at(i32, &CStr) pair with a single make_dir(Option<crt_fd::Borrowed<'_>>, &Path, mode). Non-Unix falls back to std::fs::create_dir or returns Unsupported; Unix and WASI delegate to rustix::fs::mkdirat with CWD when no fd is given. |
os stdlib mkdir caller and platform flags crates/vm/src/stdlib/os.rs |
Simplifies cfg_select! AT_FDCWD condition to any(unix, target_os = "wasi"), changes MKDIR_DIR_FD from non-windows/non-redox to cfg!(unix), adds Path to std imports, and rewrites mkdir to call host_env::posix::make_dir with dir_fd.get_opt() and Path::new. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- RustPython/RustPython#7604: Introduced the
crt_fd::Borrowedabstraction and the originalmake_dir/make_dir_atimplementations that this PR directly replaces. - RustPython/RustPython#7636: Also modifies the
cfg_select!AT_FDCWD/directory-fd fallback condition incrates/vm/src/stdlib/os.rs.
Suggested reviewers
- youknowone
🐇 Hop, hop, hooray for paths so clean,
No more rawi32hiding between!
Option<Borrowed>and&Pathnow unite,
mkdirathums with rustix delight.
Onemake_dirto rule them all tonight! 🌿
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Title check | The title references Windows and Redox support, but the actual changes focus on refactoring the make_dir API to accept optional directory file descriptors and changing platform conditionals for Unix/non-Unix, not primarily adding Windows/Redox support. |
Consider retitling to reflect the core changes, e.g., 'Refactor make_dir API to support optional directory file descriptors' or 'Simplify make_dir with unified API for directory operations'. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.