MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / copy_dir_all

Function copy_dir_all

flow-quickstart/src/git.rs:207–251  ·  view source on GitHub ↗
(src: impl AsRef<Path>, dst: impl AsRef<Path>)

Source from the content-addressed store, hash-verified

205}
206
207fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> {
208 fn check_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> {
209 if !dst.as_ref().exists() {
210 return Ok(());
211 }
212
213 for src_entry in fs::read_dir(src)? {
214 let src_entry = src_entry?;
215 let dst_path = dst.as_ref().join(src_entry.file_name());
216 let entry_type = src_entry.file_type()?;
217
218 if entry_type.is_dir() {
219 check_dir_all(src_entry.path(), dst_path)?;
220 } else if entry_type.is_file() {
221 if dst_path.exists() {
222 warn!(
223 "{} {}",
224 style("File already exists:").bold().red(),
225 style(dst_path.display()).bold().red(),
226 )
227 }
228 } else {
229 warn!("{}", style("Symbolic links not supported").bold().red(),)
230 }
231 }
232 Ok(())
233 }
234 fn copy_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> {
235 fs::create_dir_all(&dst)?;
236 for src_entry in fs::read_dir(src)? {
237 let src_entry = src_entry?;
238 let dst_path = dst.as_ref().join(src_entry.file_name());
239 let entry_type = src_entry.file_type()?;
240 if entry_type.is_dir() {
241 copy_dir_all(src_entry.path(), dst_path)?;
242 } else if entry_type.is_file() {
243 fs::copy(src_entry.path(), dst_path)?;
244 }
245 }
246 Ok(())
247 }
248
249 check_dir_all(&src, &dst)?;
250 copy_all(src, dst)
251}
252
253fn git_clone_all(project_dir: &Path, args: GitConfig) -> Result<String> {
254 let mut builder = RepoBuilder::new();

Callers 2

copy_allFunction · 0.85
git_clone_allFunction · 0.85

Calls 2

check_dir_allFunction · 0.85
copy_allFunction · 0.85

Tested by

no test coverage detected