Inverse of the default pathBuild(): splits the path on / (or, for tarname inputs, on _), strips archive extensions and the pre prefix, then matches segments positionally to scenarioFields(). Integer ranges of the form start-end decode to integer vectors.

pathParse(
  path,
  fields = scenarioFields(),
  pre = "outputs",
  withFieldLabel = .scenario_env$withFieldLabel
)

Arguments

path

A single character string (path or tarname).

fields

Field labels in scenario order; defaults to scenarioFields() (set by queueRead()).

pre

Path prefix to strip (default "outputs").

withFieldLabel

Character vector of field names that were built with paste0(label, value) prefixing.

Value

Named list of field values (in fields order).

Details

Without per-segment labels there is no way to recover which field a missing segment corresponds to, so when the path has fewer segments than there are fields, the trailing fields are treated as NA. Round-trip is therefore only lossless when NA-bearing fields are last in the field order unless you label the ambiguous fields through withFieldLabel: any field named there has its label prefix stripped from the segment, and segments not starting with a labeled field's name are assigned positionally to the next unlabeled field. With every potentially-NA field labeled, mid-list NAs round-trip cleanly.