Skip to main content

write_file

Function write_file 

Source
pub fn write_file(path: &Path, bytes: &[u8]) -> Result<(), String>
Expand description

Write bytes to path through a temporary file beside it and a rename, never wider than the file it replaces. On Unix the temporary file is created owner-only (0600) from the start, so the bytes are never readable by others for a moment. A file being replaced then keeps its own mode, except a .mcp.json, which holds signing keys and is always 0600, as AgentMux writes it (Workdir::write(.., owner_only = true)); a new file stays 0600. On Windows the file takes its folder’s ACL, as every write through Workdir does: the profile’s per-user ACL.