touch: move platform-specific code into platform/ - #13906
Conversation
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR refactors touch by extracting platform-specific behavior into a dedicated platform/ module to reduce conditional code in touch.rs and centralize OS-specific implementations.
Changes:
- Introduces
src/uu/touch/src/platform/with Windows- and WASI-specific implementations. - Moves WASI
set_file_times/set_symlink_file_timesintoplatform/wasi.rs. - Moves Windows
pathbuf_from_stdoutintoplatform/windows.rsand wires exports viaplatform/mod.rs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/uu/touch/src/touch.rs | Routes platform-specific helpers through a new platform module and removes inline WASI/Windows implementations. |
| src/uu/touch/src/platform/mod.rs | Adds platform re-exports and module declarations for Windows and WASI implementations. |
| src/uu/touch/src/platform/windows.rs | New Windows-specific pathbuf_from_stdout() implementation. |
| src/uu/touch/src/platform/wasi.rs | New WASI-specific file timestamp setters and stdout-path behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // SAFETY: We transmute the handle to be able to cast *mut c_void into a | ||
| // HANDLE (i32) so rustc will let us call GetFinalPathNameByHandleW. The | ||
| // reference example code for GetFinalPathNameByHandleW implies that | ||
| // it is safe for us to leave lpszfilepath uninitialized, so long as | ||
| // the buffer size is correct. We know the buffer size (MAX_PATH) at | ||
| // compile time. MAX_PATH is a small number (260) so we can cast it | ||
| // to a u32. |
| use uucore::{format_usage, show}; | ||
|
|
||
| use crate::error::TouchError; | ||
| #[cfg(not(unix))] |
| #[cfg(unix)] | ||
| #[expect(clippy::unnecessary_wraps)] | ||
| fn pathbuf_from_stdout() -> Result<PathBuf, TouchError> { |
|
@DePasqualeOrg wdyt? |
|
Looks like a straightforward change to me. I ran an automated review with Codex, and it suggested the following:
|
i tried that too but it doesn't bring much |
Merging this PR will degrade performance by 3.4%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
No description provided.