Skip to content

Commit

Permalink
fix glob on windows, with slight regression
Browse files Browse the repository at this point in the history
  • Loading branch information
meggart committed Dec 11, 2024
1 parent ddd98d6 commit 2d1de9d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/DatasetAPI/Datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,17 @@ testrange(x::AbstractArray{<:TimeType}) = x

testrange(x::AbstractArray{<:AbstractString}) = x

_glob(x) = startswith(x, "/") ? glob(x[2:end], "/") : glob(x)

# This is a bit unfortunate since it will disallow globbing hierarchies of directories,
# but necessary to have it work on both windows and Unix systems
function _glob(x)
if isabspath(x)
p, rest = splitdir(x)
glob(rest,p)
else
glob(x)
end
end

open_mfdataset(g::AbstractString; kwargs...) = open_mfdataset(_glob(g); kwargs...)
open_mfdataset(g::Vector{<:AbstractString}; kwargs...) =
Expand Down

0 comments on commit 2d1de9d

Please sign in to comment.