Skip to content

touch: move platform-specific code into platform/ - #13906

Merged
sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:touch-move
Aug 13, 2026
Merged

touch: move platform-specific code into platform/#13906
sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:touch-move

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings August 13, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_times into platform/wasi.rs.
  • Moves Windows pathbuf_from_stdout into platform/windows.rs and wires exports via platform/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.

Comment thread src/uu/touch/src/platform/windows.rs
Comment on lines +29 to +35
// 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.
Comment thread src/uu/touch/src/touch.rs
use uucore::{format_usage, show};

use crate::error::TouchError;
#[cfg(not(unix))]
Comment thread src/uu/touch/src/touch.rs
Comment on lines +907 to 909
#[cfg(unix)]
#[expect(clippy::unnecessary_wraps)]
fn pathbuf_from_stdout() -> Result<PathBuf, TouchError> {
@sylvestre

Copy link
Copy Markdown
Contributor Author

@DePasqualeOrg wdyt?

@DePasqualeOrg

Copy link
Copy Markdown
Contributor

Looks like a straightforward change to me. I ran an automated review with Codex, and it suggested the following:

Move the Unix pathbuf_from_stdout() into platform/unix.rs too. That would centralize the complete cross-platform interface and eliminate the slightly imprecise #[cfg(not(unix))] import.

@sylvestre

Copy link
Copy Markdown
Contributor Author

Move the Unix pathbuf_from_stdout() into platform/unix.rs too. That would centralize the complete cross-platform interface and eliminate the slightly imprecise #[cfg(not(unix))] import.

i tried that too but it doesn't bring much

@sylvestre
sylvestre merged commit e1efa7d into uutils:main Aug 13, 2026
165 of 167 checks passed
@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.4%

❌ 1 regressed benchmark
✅ 346 untouched benchmarks
🆕 10 new benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation numfmt_large_numbers_si[10000] 94.7 ms 98.1 ms -3.4%
🆕 Memory ptx_input_references_short_lines[100000] N/A 222.2 MB N/A
🆕 Memory ptx_long_lines[100] N/A 29.5 MB N/A
🆕 Memory ptx_short_lines[100000] N/A 240.1 MB N/A
🆕 Memory ptx_input_references_long_lines[1000] N/A 29.1 MB N/A
🆕 Memory ptx_tex[10000] N/A 20.6 MB N/A
🆕 Simulation ptx_input_references_short_lines[100000] N/A 16.1 s N/A
🆕 Simulation ptx_long_lines[100] N/A 1.7 s N/A
🆕 Simulation ptx_short_lines[100000] N/A 14 s N/A
🆕 Simulation ptx_input_references_long_lines[1000] N/A 2 s N/A
🆕 Simulation ptx_tex[10000] N/A 2.9 s N/A

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sylvestre:touch-move (9a1d1d8) with main (66cf72b)2

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (e6561b5) during the generation of this report, so 66cf72b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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.

3 participants