Problem with File::getNonexistentSibling()


#1

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?


#2

You mean the argument has no effect?

It is done here:

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


#3

Yes, it seems intentional, I feel confused.

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


#4

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…


#5

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:


#6

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


#7

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:


#8

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.