diff options
author | Kevin Leimkuhler <kevin@kleimkuhler.com> | 2020-04-02 14:10:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 17:10:44 -0400 |
commit | 3eaa1885c314345f3fa0022e8a04af4f159f2365 (patch) | |
tree | 4f7c32e427a938faac6bea66a632bb1c2f54fb21 /tokio/src/fs | |
parent | cf4cbc142bd8198d2112cf671c120740fdc4e132 (diff) |
fs: Copy file permissions (#2354)
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
Diffstat (limited to 'tokio/src/fs')
-rw-r--r-- | tokio/src/fs/copy.rs | 10 |
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 } |