2 // Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "supertux/levelset.hpp"
22 #include "util/log.hpp"
23 #include "util/string_util.hpp"
25 Levelset::Levelset(const std::string& basedir) :
29 char** files = PHYSFS_enumerateFiles(m_basedir.c_str());
32 log_warning << "Couldn't read subset dir '" << m_basedir << "'" << std::endl;
36 for(const char* const* filename = files; *filename != 0; ++filename)
38 if(StringUtil::has_suffix(*filename, ".stl"))
40 m_levels.push_back(*filename);
43 PHYSFS_freeList(files);
45 std::sort(m_levels.begin(), m_levels.end(), StringUtil::numeric_less);
49 Levelset::get_num_levels() const
51 return static_cast<int>(m_levels.size());
55 Levelset::get_level_filename(int i) const