.hasFileExtension () with multiple extensions not working?


#1

Hi,

I was interested with the new feature of File . hadFileExtension() , but it seems it’s not working yet ?
if (f.hasFileExtension (T(".mp3"))) works, but
if (f.hasFileExtension (T(".mp3;wav"))) don’t
I tried various things but no sucess…
Is it broken in the tip ?

Salvator


#2

I’ve been using it like that in a project and it seems to work perfectly…


#3

well, then I’m an orphean case …

Could it be that the parsing of extension vary from system to system ?
Anyone else have it working or not ?

Salvator

BTW jules : I often see examples where people you use string “text” without having to do the T (" ") macro.
How to setup xcode for that please ?


#4

Not sure whether this would help but shouldn’t your code change to

instead of if (f.hasFileExtension (T(".mp3;wav")))


#5

It doesn’t matter whether you put a dot in front of the extensions, or not.

I’d suggest stepping into it and seeing what happens in the method, that’s normally the quickest way to spot what’s going on.

[quote]BTW jules : I often see examples where people you use string “text” without having to do the T (" ") macro.
How to setup xcode for that please ?[/quote]

There’s nothing to set up - any parameter that takes a String can be passed a normal char* (as long as it only contains ascii characters)


#6

Hello,

Thanks vishvesh, yes I tried that already but as jules said, it makes no diff.
The problem is resolved by now anyway !
Don’t know exactly what happenned, I guess it could have been some cache problem weirdness in my xcode, or need of another clean build etc.
At first, the function was not even called (I’m serious !), but after adding/removing some DBG statments in the function, it now work fine. :mrgreen: Whatever the problem was …
Sorry for the noise !

PS to Jules : concerning the T("") thing, sometimes there’s function like the xml element example :

XmlElement* myElement; bool b = myElement->hasTagName ("ANIMALS")
But brings error at my place :

error: no matching function for call to 'juce::XmlElement::hasTagName(char [8])' note: candidates are: bool juce::XmlElement::hasTagName(const juce::tchar*) const
But it works when if I write T("ANIMALS")
I found a thread about this (http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=1310), but error persist whatever I define
#define JUCE_STRINGS_ARE_UNICODE to 1 or 0, or comment it out (in appconfig or juce_amalgamated.cpp).
I would greatly have my code cleaned from all those numerous T("") I use, which make things more cluttered to read (in regards to parenthesis)
Any hint on how you do ?

Thanks,

Salvator


#7

Like I said, methods that take a String will take a char*.

But hasTagName() doesn’t take a String.


#8

Hi Jules,

Yes, I understand now.
But then I’m still confused on why the example code from the doc of XmlElement exactly use myElement->hasTagName ("ANIMALS")
I assumed that (as it’s example code) it would work, no ?
So maybe if not, you may modify the example code in the doc then ?

Thanks,

Salvator


#9

Oops, sorry - that looks like a typo in the docs…