15 #include <boost/test/unit_test.hpp>
25 for(
typename T::const_iterator k = v.begin(); k != v.end(); ++k) {
26 std::cerr <<
" * " << *k <<
'\n';
43 const size_t strip_len = (maincfg +
"/data/").
length();
44 BOOST_REQUIRE(gamedata_rev.length() > strip_len);
45 gamedata_rev.resize(gamedata_rev.length() - strip_len);
47 BOOST_CHECK_EQUAL( gamedata_rev,
gamedata );
68 BOOST_CHECK_EQUAL(
base_name(
"foo/bar/baz.cfg"),
"baz.cfg" );
71 BOOST_CHECK_EQUAL(
base_name(
"foo/bar"),
"bar" );
91 const std::vector<std::string> expected_filenames = {
100 const std::vector<std::string> expected_dirnames = {
105 std::vector<std::string> files, dirs;
106 std::vector<std::string> expected_filepaths, expected_dirpaths;
109 expected_filepaths.push_back(
gamedata +
"/" + path +
"/" +
n);
113 expected_dirpaths.push_back(
gamedata +
"/" + path +
"/" +
n);
121 BOOST_CHECK( files == expected_filepaths );
122 BOOST_CHECK( dirs == expected_dirpaths );
130 gamedata +
"/images/././././././" );
133 gamedata +
"/data/core/images/wesnoth-icon.png" );
136 gamedata +
"/data/core/music/silence.ogg" );
139 gamedata +
"/data/core/sounds/explosion.ogg" );
142 "data/core/images/wesnoth-icon.png" );
168 BOOST_CHECK(
get_wml_location(
"why_would_anyone_ever_name_a_file_like_this").empty() );
173 BOOST_CHECK(
ends_with(
"foobarbazbat",
"bazbat") );
196 BOOST_AUTO_TEST_SUITE_END()
std::string get_binary_dir_location(const std::string &type, const std::string &filename)
Returns a complete path to the actual directory of a given type or an empty string if the directory i...
BOOST_AUTO_TEST_SUITE(filesystem) const std BOOST_AUTO_TEST_CASE(test_fs_game_path_reverse_engineering)
bool looks_like_pbl(const std::string &file)
bool ends_with(const std::string &str, const std::string &suffix)
BOOST_AUTO_TEST_SUITE(test_map_location)
std::string get_binary_file_location(const std::string &type, const std::string &filename)
Returns a complete path to the actual file of a given type or an empty string if the file isn't prese...
GLuint GLsizei GLsizei * length
GLsizei const char ** path
std::string get_user_data_dir()
std::string base_name(const std::string &file)
Returns the base filename of a file, with directory name stripped.
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
std::string get_independent_image_path(const std::string &filename)
Returns an image path to filename for binary path-independent use in saved games. ...
bool is_gzip_file(const std::string &filename)
Returns true if the file ends with '.gz'.
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs=nullptr, file_name_option mode=FILE_NAME_ONLY, file_filter_option filter=NO_FILTER, file_reorder_option reorder=DONT_REORDER, file_tree_checksum *checksum=nullptr)
Populates 'files' with all the files and 'dirs' with all the directories in dir.
std::string get_wml_location(const std::string &filename, const std::string ¤t_dir=std::string())
Returns a complete path to the actual WML file or directory or an empty string if the file isn't pres...
Game configuration data as global variables.
bool is_compressed_file(const std::string &filename)
Declarations for File-IO.
bool is_bzip2_file(const std::string &filename)
Returns true if the file ends with '.bz2'.
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
GLsizei const GLcharARB ** string
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.