Problem with File::getNonexistentSibling()


Happy new year, everyone!

File::getNonexistentSibling (false) has no effect when the filename made of digits. It just works for characters-filename. Is it a bug or I missed something?


You mean the argument has no effect?

It is done here:

So yes, it’s intentional. But I don’t know why…


Yes, it seems intentional, I feel confused.

Couldn’t it be fine: A00.txt -> A00-2.txt, rather than A00(2).txt?


I could imagine, because adding a digit to a number changes it’s value. As an automatic change you wouldn’t notice it easily.
With the dash though you would be fine. But the default implementation doesn’t add a dash.

If a file backup-30-12-2017.txt becomes backup-30-12-20171.txt would be annoying…
Incrementing the number would also be a bad idea. So it needs to be prominent, hence the brackets I think…


So there’s no any difference between File::getNonexistentSibling (true) and File::getNonexistentSibling (false) when a file’s name ends up with a digit… :confused:


I think your idea to add a dash in that specific case would be nice…
Maybe someone from the juce team picks that up…


Hope so…

TBH, I think there’s no need using a bool arg with that method. Just a ‘naked’ will be fine (use “-” for prominent).

Thanks for your reply, daniel :slight_smile:


Yup, fair point. I’d probably go for an underscore rather than a dash, but it does seem like the behaviour should differ based on that parameter.