Closed Property404 closed 2 years ago
Thanks for the PR, although I am not quite sure this would be the expected behaviour. AFAICT the parent of the root being the root is a result of making the implementation of paths simpler, by enforcing every path having a parent.
This change would cause internal inconsistencies since currently root.parent() == None
.
Navigating to ".." from root is probably an error or at least not intended. I'd rather have a proper Error when resolving such paths. To better understand the use case, do you have any concrete examples where this behaviour might be useful?
My use case is that I use VFS to emulate a unix-like system, and the current behavior causes unexpected results
Quote from Stackoverflow: "While it may seem seem more logical to throw an error, this behavior allows all directories to be treated the same rather than having to treat the root directory as a special case."
And I think that makes sense, at least for what I'm doing. But I'm not sure what other people are using this crate for
Added a fixup!
for the VfsPath::parent()
issue
Fixed doc comment and squashed/rebased
In unix systems, trying to access the parent of root will return root. This commit implements that behavior.