blob: 0050cf1b3e932eda4430b343151b0f9eff145046 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
pub async fn move_across_partitions(
source_path: impl AsRef<std::path::Path>,
dest_path: impl AsRef<std::path::Path>,
) -> Result<(), std::io::Error> {
let source_path = source_path.as_ref();
let dest_path = dest_path.as_ref();
if !source_path.exists() {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"Source file does not exist",
));
}
if let Ok(()) = std::fs::rename(source_path, dest_path) {
return Ok(());
}
std::fs::copy(source_path, dest_path)?;
std::fs::remove_file(source_path)?;
Ok(())
}
pub async fn copy_across_partitions(
source_path: impl AsRef<std::path::Path>,
dest_path: impl AsRef<std::path::Path>,
) -> Result<(), std::io::Error> {
let source_path = source_path.as_ref();
let dest_path = dest_path.as_ref();
if !source_path.exists() {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"Source file does not exist",
));
}
std::fs::copy(source_path, dest_path)?;
Ok(())
}
|