Imagine that you have

'/tmp/a/b' folder containing 'c' file

'/tmp/a/b' asFileReference ensureCreateDirectory.
'/tmp/a/b/c' asFileReference writeStreamDo: [ :s | s nextPutAll: 'contents'
].

now there are three ways how you can see the contents of the c file

x := '/tmp/a/b/c.txt' asFileReference.
y := '/tmp' asFileReference /  'a' / 'b' / 'c.txt'.
z := '/tmp' asFileReference / 'a/b/c.txt'.

They clearly all point to the same file:

x contents = y contents "true"
x contents = z contents "true"

Yet the last option is different

x = y "true"
x = z "false"

Why is that? Because the parent is different:

x parent pathString "'/tmp/a/b'"
y parent pathString "'/tmp/a/b'"
z parent pathString "'/tmp'"

So the parent is based on how the reference was constructed, not what it is
actually pointing to, which is stupid.

Is this a bug? Is this a (nasty) expected behavior?

Peter

Reply via email to