Is that true, nPath always ends with a trailing '/'? There is no risk of dropping the last path element?

Side note: You probably chose not to, but falling-through on some of these "cases" could reduce some duplicate code.