MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / copy_folder_content

Function copy_folder_content

rust/src/files.rs:567–611  ·  view source on GitHub ↗
(
    source: impl AsRef<Path>,
    destination: impl AsRef<Path>,
    single_file: Option<String>,
    avoid_path: &PathBuf,
    log: &Logger,
)

Source from the content-addressed store, hash-verified

565}
566
567pub fn copy_folder_content(
568 source: impl AsRef<Path>,
569 destination: impl AsRef<Path>,
570 single_file: Option<String>,
571 avoid_path: &PathBuf,
572 log: &Logger,
573) -> io::Result<()> {
574 fs::create_dir_all(&destination)?;
575 for dir_entry in fs::read_dir(source)? {
576 let entry = dir_entry?;
577 let file_type = entry.file_type()?;
578 let destination_path = destination.as_ref().join(entry.file_name());
579 if file_type.is_file() {
580 if entry.path().eq(avoid_path) {
581 continue;
582 }
583 let target_file_name = entry
584 .file_name()
585 .to_os_string()
586 .into_string()
587 .unwrap_or_default();
588 if single_file.is_none()
589 || (single_file.is_some() && single_file.clone().unwrap().eq(&target_file_name))
590 {
591 log.trace(format!(
592 "Copying {} to {}",
593 entry.path().display(),
594 destination_path.display()
595 ));
596 if !destination_path.exists() {
597 fs::copy(entry.path(), destination_path)?;
598 }
599 }
600 } else if single_file.is_none() {
601 copy_folder_content(
602 entry.path(),
603 destination_path,
604 single_file.clone(),
605 avoid_path,
606 log,
607 )?;
608 }
609 }
610 Ok(())
611}
612
613pub fn default_cache_folder() -> PathBuf {
614 if let Some(base_dirs) = BaseDirs::new() {

Callers 1

unzipFunction · 0.85

Calls 4

copyFunction · 0.85
traceMethod · 0.80
pathMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected