Converts a `raw_location`, which needn't exist but must represent a file (not a directory), to its canonical form. If `extension` is not empty, adds it to the location if it didn't not yet have nay.
(
&self,
raw_location: &str,
extension: &str,
)
| 421 | /// |
| 422 | /// If `extension` is not empty, adds it to the location if it didn't not yet have nay. |
| 423 | pub fn make_canonical_with_extension( |
| 424 | &self, |
| 425 | raw_location: &str, |
| 426 | extension: &str, |
| 427 | ) -> io::Result<String> { |
| 428 | let mut location = Location::new(raw_location)?; |
| 429 | if location.drive.is_none() { |
| 430 | location.drive = Some(self.current.clone()); |
| 431 | } |
| 432 | if location.leaf_name().is_none() { |
| 433 | return Err(io::Error::new( |
| 434 | io::ErrorKind::NotFound, |
| 435 | format!("Missing file name in path '{}'", raw_location), |
| 436 | )); |
| 437 | } |
| 438 | location.set_extension(extension); |
| 439 | Ok(location.to_string()) |
| 440 | } |
| 441 | |
| 442 | /// Attaches a new `drive` with `name`, which was instantiated with `uri`. |
| 443 | /// |
no test coverage detected