Copies a file from source to destination, preserving file permissions.
(from: &Path, to: &Path)
| 121 | |
| 122 | /// Copies a file from source to destination, preserving file permissions. |
| 123 | pub async fn copy_file(from: &Path, to: &Path) -> Result<()> { |
| 124 | tokio::fs::copy(from, to).await?; |
| 125 | let metadata = tokio::fs::metadata(from).await?; |
| 126 | tokio::fs::set_permissions(to, metadata.permissions()).await?; |
| 127 | Ok(()) |
| 128 | } |
| 129 | |
| 130 | #[cfg(test)] |
| 131 | mod tests { |
no outgoing calls