On 1 December 2017 at 17:32, Prof. Andrew P. Black <
[hidden email]> wrote:
> I have a file reference containing multiple occurrences of .., like this
>
> File @
> /Users/black/graceProgs/lists/../../Development/mg/gracelang/albums_junk.grace
>
> How do I simplify this to show the simpler path without the .. ? There
> should be a method on FileReference, no? Something like #normalize ? Or
> maybe FileReference should do this automatically when it is created?
The answer will depend on which version of Pharo you are using, but for Pharo7:
'/Users/black/graceProgs/lists/../../Development/mg/gracelang/albums_junk.grace'
asFileReference canonicalize
"File @ /Users/black/Development/mg/gracelang/albums_junk.grace"
The reason the '..' segments are left in is because while the result
is probably what you are looking for, if the original reference
contains symbolic links you may end up with a different result to what
the file system will return.
Cheers,
Alistair