// Generate a symlink at the given path, linking randomly to one of the potential_folders or potential_files.
// The link's path to the target will be relative.
// If no targets are possible, or randomly, a bad symlink will be generated
Generate a symlink at the given path, linking randomly to one of the potential_folders or potential_files.
The link's path to the target will be relative.
If no targets are possible, or randomly, a bad symlink will be generated
Generate a symlink at the given path linking randomly to one of the potential_folders or potential_files . The link ' s path to the target will be relative . If no targets are possible or randomly a bad symlink will be generated
fn generate_random_symlink<P: AsRef<Path>>(&mut self, path: P, potential_files: &[PathBuf], potential_folders: &[PathBuf]) {
		let target = if self.rng.gen() {
			if self.rng.gen() {
				None // Bad symlink
			} else {
				potential_files.choose(&mut self.rng)
			}
		} else {
			potential_folders.choose(&mut self.rng)
		};
		let target = match target {
			Some(target) => TestGenerator::calculate_relative_path(path.as_ref().parent().unwrap(), target),
			None => PathBuf::from(self.generate_random_name()),  // Bad symlink
		};
		unix::fs::symlink(target, path.as_ref()).unwrap();
		self.set_random_filetime(path.as_ref());
	}
fn generate_random_symlink < P : AsRef < Path > > ( & mut self , path : P , potential_files : & [ PathBuf ] , potential_folders : & [ PathBuf ] ) { let target = if self . rng . gen ( ) { if self . rng . gen ( ) { None // Bad symlink } else { potential_files . choose ( & mut self . rng ) } } else { potential_folders . choose ( & mut self . rng ) } ; let target = match target { Some ( target ) => TestGenerator :: calculate_relative_path ( path . as_ref ( ) . parent ( ) . unwrap ( ) , target ) , None => PathBuf :: from ( self . generate_random_name ( ) ) , // Bad symlink } ; unix :: fs :: symlink ( target , path . as_ref ( ) ) . unwrap ( ) ; self . set_random_filetime ( path . as_ref ( ) ) ; }
Generate a symlink at the given path, linking randomly to one of the potential_folders or potential_files.
Generate a symlink at the given path linking randomly to one of the potential_folders or potential_files .
&mut self
path
P
potential_files
&[PathBuf]
potential_folders
&[PathBuf]