Rename a file or directory.
(&self, from: &str, to: &str)
| 267 | |
| 268 | /// Rename a file or directory. |
| 269 | fn rename(&self, from: &str, to: &str) -> Result<(), Self::Error> { |
| 270 | let from_abs = self.resolve_path(from)?; |
| 271 | let to_abs = self.resolve_path(to)?; |
| 272 | |
| 273 | // Create parent directory for destination if needed |
| 274 | if let Some(parent) = to_abs.parent() { |
| 275 | if !parent.exists() { |
| 276 | fs::create_dir_all(parent)?; |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | fs::rename(&from_abs, &to_abs) |
| 281 | } |
| 282 | |
| 283 | /// Set permissions on a file or directory. |
| 284 | fn set_permissions(&self, path: &str, permissions: u16) -> Result<(), Self::Error> { |