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

Function check_dir_all

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

Source from the content-addressed store, hash-verified

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)? {

Callers 1

copy_dir_allFunction · 0.85

Calls 1

as_refMethod · 0.80

Tested by

no test coverage detected