This will go wrong, you need to call dirname on `$path` and use that in the resolvePath call.

Internal path is relative to the storage and thus will never go outside the storage with dirname