MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / build_single_file_archive

Function build_single_file_archive

crates/openshell-cli/src/ssh.rs:2020–2034  ·  view source on GitHub ↗
(entry_path: &str, bytes: &[u8])

Source from the content-addressed store, hash-verified

2018 }
2019
2020 fn build_single_file_archive(entry_path: &str, bytes: &[u8]) -> Vec<u8> {
2021 let mut buf = Vec::new();
2022 {
2023 let mut builder = tar::Builder::new(&mut buf);
2024 let mut header = tar::Header::new_gnu();
2025 header.set_path(entry_path).expect("set tar entry path");
2026 header.set_size(bytes.len() as u64);
2027 header.set_mode(0o644);
2028 header.set_entry_type(tar::EntryType::Regular);
2029 header.set_cksum();
2030 builder.append(&header, bytes).expect("append tar entry");
2031 builder.finish().expect("finish tar archive");
2032 }
2033 buf
2034 }
2035
2036 fn unpack_into(archive_bytes: &[u8], staging: &Path) {
2037 let mut archive = tar::Archive::new(std::io::Cursor::new(archive_bytes));

Calls 2

set_pathMethod · 0.80
lenMethod · 0.80