Rename a file or directory.
(&self, from: &str, to: &str)
| 290 | |
| 291 | /// Rename a file or directory. |
| 292 | fn rename(&self, from: &str, to: &str) -> Result<(), Self::Error> { |
| 293 | let from_abs = self.resolve_path(from)?; |
| 294 | let to_abs = self.resolve_path(to)?; |
| 295 | |
| 296 | // Create parent directory for destination if needed |
| 297 | if let Some(parent) = to_abs.parent() { |
| 298 | if !parent.exists() { |
| 299 | fs::create_dir_all(parent)?; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | fs::rename(&from_abs, &to_abs) |
| 304 | } |
| 305 | |
| 306 | /// Set permissions on a file or directory. |
| 307 | fn set_permissions(&self, path: &str, permissions: u16) -> Result<(), Self::Error> { |