feat: bootstrap awg2 harness rust workspace and docs

This commit is contained in:
2026-05-09 02:17:25 +05:00
commit d937f816bf
47 changed files with 4195 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
use std::{fs, path::Path};
pub struct FileLock {
path: String,
}
impl FileLock {
pub fn acquire(path: &str) -> anyhow::Result<Self> {
let p = Path::new(path);
if let Some(parent) = p.parent() {
fs::create_dir_all(parent)?;
}
if p.exists() {
anyhow::bail!("lock already exists: {path}");
}
fs::write(p, std::process::id().to_string())?;
Ok(Self {
path: path.to_string(),
})
}
}
impl Drop for FileLock {
fn drop(&mut self) {
let _ = fs::remove_file(&self.path);
}
}