summaryrefslogtreecommitdiffstats
path: root/tokio/src/fs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio/src/fs')
-rw-r--r--tokio/src/fs/copy.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/tokio/src/fs/copy.rs b/tokio/src/fs/copy.rs
index e39924c5..d4d4d29c 100644
--- a/tokio/src/fs/copy.rs
+++ b/tokio/src/fs/copy.rs
@@ -1,5 +1,4 @@
-use crate::fs::File;
-use crate::io;
+use crate::fs::asyncify;
use std::path::Path;
/// Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.
@@ -19,8 +18,7 @@ use std::path::Path;
/// ```
pub async fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64, std::io::Error> {
- let from = File::open(from).await?;
- let to = File::create(to).await?;
- let (mut from, mut to) = (io::BufReader::new(from), io::BufWriter::new(to));
- io::copy(&mut from, &mut to).await
+ let from = from.as_ref().to_owned();
+ let to = to.as_ref().to_owned();
+ asyncify(|| std::fs::copy(from, to)).await
}