Split path to its parts

I want to split a path into all its directory names. On Linux I would achieve this with split and a the path separator of /:

julia>             split("/home/me/some/thing", '/')
5-element Array{SubString{String},1}:

But it would be nice if this worked everywhere. Or if these was a better way…


I went looking for this functionality recently too. And we’re not alone


See also https://github.com/JuliaLang/julia/pull/28156


While this is fixed in Base, a (trivial) package could be very useful. I guess the only thing it needs to do is encode platform-dependent behavior.

I had forgotten about that PR but I think we should merge it.

Oh wow, awesome.

So once/if that PR is merged, what would a package help with?

I was assuming the PR was dormant. If it is merged, that’s of course preferable.

1 Like

Merged so in Julia 1.1 you’ll be able to call splitpath. This change could potentially be added to Compat to allow use splitpath on older Julia versions.