Break the loop in stat since the first element is "." or the file.
With my changes the break in
stat becomes necessary. As now the resulting
pathUDSResults will have different names based on the path. The first one being the one for "." in case of a file of the file in case of a file.
The code is IMO a bit convoluted and hard to follow with this
parseUrl used both for stat and list which makes it harder to follow through and ParseResult being this too-genric bag of result things. I did not understand it fully.