My code sometimes gets paths that point to the secondary volume of a volume group.
For instance, on a Catalina or Big Sur startup volume, where there's a System and a Data role member, I may have a path such as:
/System/Volumes/Data/usr/local/bin
The regular ("normalized") path would be:
/usr/local/bin
How do I turn the first path into the second, using available macOS framework functions (Obj-C or Swift)?
Note that I don't want to simply hard-code a string replacement for this, because, at least on Big Sur, the same also happens with other mounted volumes that are in a group. For instance, I may have another bootable system with 10.15, whose volume is named "Catalina", and the two volumes then would appear as:
System: /Volumes/Catalina Data: /Volumes/Catalina - Data
Now, if I get a path like /Volumes/Catalina - Data/Users/Shared
, I want to normalize that into /Volumes/Catalina/Users/Shared
.