Infinite recursion in File::isAChildOf()


#1

Hi,

the following code is producing an infinite recursion (on MacOSX, but probably on other platforms too – on the current git version):

Should the existence of the file not be tested inside isAChildOf() ?
The infinite loop comes from getParentDirectory() that, when called on a system root, returns the system root itself. This seems a bit counter intuitive: I would expect that the parent directory of a system root is something like File::nonexistent … Maybe this behavior could be changed in juce ?

Francis.


#2

It’s a deep philosophical question: can a file be the child of nothing… I guess the method is just going off into a zen-buddhist trance as it tries to comtemplate the correct answer.

I’ll sort that out. The question “what is the parent of the root directory” is also pretty difficult! I don’t think I could change it to return File::nonexistent without breaking code, but I’m not convinced that it’d be the correct thing to do anyway… It’s a tricky one.


#3

Yes, definitely. I often use the file classes to construct hierarchies that don’t yet exist, and then create them.