- Don't duplicate/allocate the path on each recursion, instead make a single copy which is modified in-place. - Move slash-stepping to a BLI_path utility function that accesses the end position of the parent directory, handles multiple slashes and '/./'.