DirectoryIterator and wildcard filter not returning files


when i do

AudioFormatManager::getInstance()->registerFormat (new MADAudioFormat (), true);
AudioFormatManager::getInstance()->registerFormat (new MPCAudioFormat (), false);

DirectoryIterator di (File(T("d:\\mp3:)), true, AudioFormatManager::getInstance()->getWildcardForAllFormats());

and try to call i get no results (literally 0 files, i have mp3/ogg/mpc files in there for testing)

but when i change the wildcard filter to:

DirectoryIterator di (File(T("d:\\mp3:)), true, T("*"));

i get results.

Is the AudioFormatManager wildcard format incompatible with the DirectoryIterator ? When i look at the wildcard returned by the AudioFormatManager it looks OK

AudioPlayerMediaWatcher::run looking for files *.mp3;*.mp2;*.mpg;*.mpc;*.wav;*.bwf;*.aiff;*.aif;*.flac;*.ogg

Another problem:
also if i use the AudioFormatManager() as a singleton like so

AudioFormatReader *r = AudioFormatManager::getInstance()->createReaderFor (f);

i always get a memory leak

Detected memory leaks!
Dumping objects ->
c:\devel\juce\src\juce_appframework\audio\audio_file_formats\juce_audioformatmanager.h(142) : {60429} normal block at 0x03838958, 24 bytes long.
 Data: <                > 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 
Object dump complete.

it doesn’t matter if i register any format or if i don’t it’s always there (it’s Win32 VISTA VC2008)


Yes, DirectoryIterators just take a single wildcard expression, so that wouldn’t work. I guess it’d be a good addition to the DirectoryIterator class to allow more complex ones.

And yes, of course you’ll get a leak if you leave the singleton lying around! You’d need to call its deleteSingletonInstance method in your shutdown code to clean up.


thanks for the singleton tip, i though those get destroyed at shutdown.


For a lot of singletons I’ve made them DeletedAtShutdown, which does the job for you, but the device manager can be used as a non-singleton as well (that’s how I normally use it), so I left it up to the user to delete it.