mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-19 16:10:53 +00:00
add src and dst detection for utils copy_dir
Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
parent
1f3257da70
commit
a85c12a12f
@ -212,6 +212,12 @@ pub fn try_infer_extension(path: &Path) -> Option<Extension> {
|
|||||||
|
|
||||||
/// Copy the src directory into the dst directory recursively
|
/// Copy the src directory into the dst directory recursively
|
||||||
pub fn copy_dir(src: &Path, dst: &Path) -> crate::Result<()> {
|
pub fn copy_dir(src: &Path, dst: &Path) -> crate::Result<()> {
|
||||||
|
if !src.exists() || !dst.exists() {
|
||||||
|
return Err(crate::Error::NotFound {
|
||||||
|
error_title: "source or destination directory does not exist".to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
for entry in fs::read_dir(src)? {
|
for entry in fs::read_dir(src)? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
let ty = entry.file_type()?;
|
let ty = entry.file_type()?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user