diff --git a/src/audio/music_manager.cpp b/src/audio/music_manager.cpp index c9d9d96b2..a774141a9 100644 --- a/src/audio/music_manager.cpp +++ b/src/audio/music_manager.cpp @@ -109,7 +109,28 @@ void MusicManager::loadMusicInformation() } // for dir } // loadMusicInformation -//----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- +void MusicManager::loadMusicFromOneDir(const std::string& dir) +{ + std::set files; + file_manager->listFiles(files, dir, /*is_full_path*/ true, + /*make_full_path*/ true); + for(std::set::iterator i = files.begin(); i != files.end(); ++i) + { + if(StringUtils::getExtension(*i)!="music") continue; + try + { + m_all_music[StringUtils::getBasename(*i)] = new MusicInformation(*i); + } + catch (std::exception& e) + { + (void)e; // avoid compiler warning + continue; + } + } // for i +} // loadMusicFromOneDir + +//-----------------------------------------------------------------------------//----------------------------------------------------------------------------- void MusicManager::addMusicToTracks() { for(std::map::iterator i=m_all_music.begin(); diff --git a/src/audio/music_manager.hpp b/src/audio/music_manager.hpp index 9d4cbceb6..1a2f7f99a 100644 --- a/src/audio/music_manager.hpp +++ b/src/audio/music_manager.hpp @@ -75,7 +75,8 @@ public: * @throw runtime_error if the music file could not be found/opened */ MusicInformation *getMusicInformation(const std::string& filename); - + + void loadMusicFromOneDir(const std::string& dir); void addMusicToTracks(); };