From c02b735eeca7b057929e5cab1c8a360e8bbeb6d3 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Tue, 27 Oct 2020 12:07:09 +0000 Subject: [PATCH] Handle Windows path prefixes --- extractor/src/main.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/extractor/src/main.rs b/extractor/src/main.rs index 2200ab366b5..2601ab63b6a 100644 --- a/extractor/src/main.rs +++ b/extractor/src/main.rs @@ -57,10 +57,20 @@ fn path_for(dir: &Path, path: &Path, ext: &str) -> PathBuf { let mut result = PathBuf::from(dir); for component in path.components() { match component { - std::path::Component::Prefix(_) => { - // skip for now - // TODO: handle this properly for Windows - } + std::path::Component::Prefix(prefix) => match prefix.kind() { + std::path::Prefix::Disk(letter) | std::path::Prefix::VerbatimDisk(letter) => { + result.push(format!("{}_", letter as char)) + } + std::path::Prefix::Verbatim(x) | std::path::Prefix::DeviceNS(x) => { + result.push(x); + } + std::path::Prefix::UNC(server, share) + | std::path::Prefix::VerbatimUNC(server, share) => { + result.push("unc"); + result.push(server); + result.push(share); + } + }, std::path::Component::RootDir => { // skip }