Skip to content

Commit de9f3cc

Browse files
committed
Reimplement touch to be crossplatform
1 parent 4fa8ee6 commit de9f3cc

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

Cargo.lock

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

collector/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ num_cpus = "1.13"
2929
jobserver = "0.1.21"
3030
crossbeam-utils = "0.7"
3131
snap = "1"
32+
filetime = "0.2.14"
3233

3334
[target.'cfg(windows)'.dependencies]
3435
miow = "0.3"

collector/src/execute.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> anyhow::Result<()>
4545
}
4646

4747
fn touch(root: &Path, path: &Path) -> anyhow::Result<()> {
48-
let mut cmd = Command::new("touch");
49-
cmd.current_dir(root).arg(path);
50-
command_output(&mut cmd).with_context(|| format!("touching {:?} in {:?}", path, root))?;
48+
let joined = root.join(path);
49+
50+
log::info!("touching file {:?}", joined);
51+
52+
filetime::set_file_mtime(&joined, filetime::FileTime::now()).with_context(|| format!("touching file {:?}", joined))?;
53+
5154
Ok(())
5255
}
5356

0 commit comments

Comments
 (0)