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

Function copy_dir_recursive

crates/openshell-driver-vm/src/driver.rs:4845–4875  ·  view source on GitHub ↗
(source: &Path, dest: &Path)

Source from the content-addressed store, hash-verified

4843}
4844
4845fn copy_dir_recursive(source: &Path, dest: &Path) -> Result<(), String> {
4846 fs::create_dir_all(dest).map_err(|err| format!("create {}: {err}", dest.display()))?;
4847 for entry in fs::read_dir(source).map_err(|err| format!("read {}: {err}", source.display()))? {
4848 let entry = entry.map_err(|err| format!("read {}: {err}", source.display()))?;
4849 let source_path = entry.path();
4850 let dest_path = dest.join(entry.file_name());
4851 let metadata = fs::symlink_metadata(&source_path)
4852 .map_err(|err| format!("stat {}: {err}", source_path.display()))?;
4853 if metadata.file_type().is_dir() {
4854 copy_dir_recursive(&source_path, &dest_path)?;
4855 } else if metadata.file_type().is_file() {
4856 if let Some(parent) = dest_path.parent() {
4857 fs::create_dir_all(parent)
4858 .map_err(|err| format!("create {}: {err}", parent.display()))?;
4859 }
4860 fs::copy(&source_path, &dest_path).map_err(|err| {
4861 format!(
4862 "copy {} to {}: {err}",
4863 source_path.display(),
4864 dest_path.display()
4865 )
4866 })?;
4867 } else {
4868 return Err(format!(
4869 "unsupported payload entry type at {}",
4870 source_path.display()
4871 ));
4872 }
4873 }
4874 Ok(())
4875}
4876
4877fn prepared_image_disk_size_bytes(
4878 payload: &GuestImagePayload,

Callers 1

Calls 1

pathMethod · 0.80

Tested by

no test coverage detected