MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / copy_dir

Function copy_dir

atomic-repository/src/repository/git_stream.rs:2080–2091  ·  view source on GitHub ↗
(from: &std::path::Path, to: &std::path::Path)

Source from the content-addressed store, hash-verified

2078 /// process leaves behind, a database redb must repair before reading.
2079 fn copy_of_open_repository(source: &std::path::Path) -> tempfile::TempDir {
2080 fn copy_dir(from: &std::path::Path, to: &std::path::Path) {
2081 std::fs::create_dir_all(to).unwrap();
2082 for entry in std::fs::read_dir(from).unwrap() {
2083 let entry = entry.unwrap();
2084 let target = to.join(entry.file_name());
2085 if entry.file_type().unwrap().is_dir() {
2086 copy_dir(&entry.path(), &target);
2087 } else {
2088 std::fs::copy(entry.path(), &target).unwrap();
2089 }
2090 }
2091 }
2092 let copy = tempfile::tempdir().unwrap();
2093 copy_dir(source, copy.path());
2094 copy

Callers 1

copy_of_open_repositoryFunction · 0.85

Calls 4

is_dirMethod · 0.80
unwrapMethod · 0.45
file_nameMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected