{"record":{"id":"0458afa9f754bf92","repo":"uutils/coreutils","slug":"writezero","errorCode":"WriteZero","errorMessage":"failed to write whole buffer","messagePattern":"failed to write whole buffer","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src/uu/cp/src/platform/windows.rs","lineNumber":98,"sourceCode":"            Ok(n) => total += n,\n            Err(e) if e.kind() == std::io::ErrorKind::Interrupted => {}\n            Err(e) => return Err(e),\n        }\n    }\n    Ok(total)\n}\n\n/// Write the whole `buf` to `file` at `offset`, looping over partial writes.\n///\n/// The Windows-only `seek_write` has no `write_all`-style counterpart (unlike\n/// the Unix `write_all_at`), so dropped tails on partial writes are handled\n/// here. The `Interrupted` arm mirrors std's own write loops, although Windows\n/// file I/O does not produce it.\nfn write_all_at(file: &File, mut buf: &[u8], mut offset: u64) -> std::io::Result<()> {\n    while !buf.is_empty() {\n        match file.seek_write(buf, offset) {\n            Ok(0) => {\n                return Err(std::io::Error::new(\n                    std::io::ErrorKind::WriteZero,\n                    \"failed to write whole buffer\",\n                ));\n            }\n            Ok(n) => {\n                buf = &buf[n..];\n                offset += n as u64;\n            }\n            Err(e) if e.kind() == std::io::ErrorKind::Interrupted => {}\n            Err(e) => return Err(e),\n        }\n    }\n    Ok(())\n}\n\n/// Error from [`sparse_copy`], separating \"the destination filesystem cannot\n/// do sparse files\" — which callers handle by falling back to a plain copy —\n/// from real I/O failures.","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/uutils/coreutils/blob/0b77ced48502a5f80c51dfa827af7e69f3687053/src/uu/cp/src/platform/windows.rs#L80-L116","documentation":"Error \"failed to write whole buffer\" thrown in uutils/coreutils.","triggerScenarios":"Occurs on Windows when cp cannot complete a write to the destination file, e.g. disk full, write to a pipe that closed early, or an I/O error mid-copy.","commonSituations":"Copying large files to a nearly-full volume, copying to a network share that disconnects, or destination media removed during the copy.","solutions":["Retry the write in a loop until all bytes are written or a non-interrupted error occurs.","Verify the destination file handle is valid and the disk is not full before copying."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0b77ced48502a5f80c51dfa827af7e69f3687053","analyzedAt":"2026-08-19T21:43:27.871Z","contentChangedAt":"2026-08-19T21:43:27.871Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}