For the Windows case, an attempt at a splitpath()
function:
# Julia 1.7:
function splitpath(epath::String)
isw() = Sys.iswindows()
ix = findall(occursin("\""), epath)
if !isempty(ix)
i0, p0 = 1, String[]
for i in 1:2:length(ix)
append!(p0, replace.(string.(split(epath[i0:ix[i]-1], isw() ? ";" : ":")), "\""=>""))
push!(p0, replace.(string(epath[ix[i]:ix[i+1]-1]), "\"" => ""))
i0 = ix[i+1]
end
if length(epath) > ix[end]
append!(p0, replace.(string.(split(epath[ix[end]+1:end], isw() ? ";" : ":")), "\""=>""))
end
else
p0 = string.(split(epath, isw() ? ";" : ":"))
end
filter!(!isempty,p0)
return p0
end
# INPUT:
epath = "c:\\usr\\local\\bin;c:\\usr\\bin;c:\\bin;\"c:\\usr\\directory name with; semicolon\\bin\";c:;\"c:\\directory2 with; semicolon\""
# OUTPUT:
splitpath(epath)
6-element Vector{String}:
"c:\\usr\\local\\bin"
"c:\\usr\\bin"
"c:\\bin"
"c:\\usr\\directory name with; semicolon\\bin"
"c:"
"c:\\directory2 with; semicolon"