37 extern std::string
path;
61 using rwops_ptr = std::unique_ptr<SDL_RWops, sdl_rwops_deleter>;
72 struct file_tree_checksum;
90 blacklist_pattern_list(
const std::vector<std::string>& file_patterns,
const std::vector<std::string>& directory_patterns)
94 bool match_file(
const std::string& name)
const;
96 bool match_dir(
const std::string& name)
const;
129 std::vector<std::string>* files,
130 std::vector<std::string>* dirs=
nullptr,
136 std::string
get_dir(
const std::string &dir);
175 std::string
get_next_filename(
const std::string& name,
const std::string& extension);
187 bool rename_dir(
const std::string& old_dir,
const std::string& new_dir);
217 bool set_cwd(
const std::string& dir);
224 bool delete_directory(
const std::string& dirname,
const bool keep_pbl =
false);
232 std::string
read_file(
const std::string& fname);
239 void write_file(
const std::string& fname,
const std::string&
data, std::ios_base::openmode mode = std::ios_base::binary);
246 void copy_file(
const std::string&
src,
const std::string& dest);
248 std::string
read_map(
const std::string& name);
338 std::string
base_name(
const std::string& file,
const bool remove_extension =
false);
376 bool normalize_separators =
false,
377 bool resolve_dot_entries =
false);
381 std::string addon_id,
382 std::string asset_type);
475 utils::optional<std::string>
get_wml_location(
const std::string&
path,
const utils::optional<std::string>& current_dir = utils::nullopt);
503 utils::optional<std::string>
get_localized_path(
const std::string& file,
const std::string& suff =
"");
A config object defines a single node in a WML file, with access to child nodes.
std::vector< std::string > file_patterns_
bool match_file(const std::string &name) const
void remove_blacklisted_files_and_dirs(std::vector< std::string > &files, std::vector< std::string > &directories) const
void add_file_pattern(const std::string &pattern)
std::vector< std::string > directory_patterns_
blacklist_pattern_list(const std::vector< std::string > &file_patterns, const std::vector< std::string > &directory_patterns)
void add_directory_pattern(const std::string &pattern)
bool match_dir(const std::string &name) const
A class grating read only view to a vector of config objects, viewed as one config with all children ...
Represents version numbers.
Interfaces for manipulating version numbers of engine, add-ons, etc.
std::string get_legacy_editor_dir()
std::string get_cache_dir()
std::time_t file_modified_time(const std::string &fname)
Get the modification time of a file.
bool is_bzip2_file(const std::string &filename)
Returns true if the file ends with '.bz2'.
int dir_size(const std::string &pname)
Returns the sum of the sizes of the files contained in a directory.
bool is_relative(const std::string &path)
Returns whether the path seems to be relative.
filesystem::scoped_istream istream_file(const std::string &fname, bool treat_failure_as_error)
bool is_root(const std::string &path)
Returns whether the path is the root of the file hierarchy.
void get_files_in_dir(const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs, name_mode mode, filter_mode filter, reorder_mode reorder, file_tree_checksum *checksum)
Get a list of all files and/or directories in a given directory.
const std::string wml_extension
bool is_cfg(const std::string &filename)
Returns true if the file ends with the wmlfile extension.
static bfs::path get_dir(const bfs::path &dirpath)
std::string get_user_data_dir()
std::string base_name(const std::string &file, const bool remove_extension)
Returns the base filename of a file, with directory name stripped.
std::string get_wml_persist_dir()
bool rename_dir(const std::string &old_dir, const std::string &new_dir)
std::string get_exe_path()
void copy_file(const std::string &src, const std::string &dest)
Read a file and then writes it back out.
bool delete_file(const std::string &filename)
bool is_gzip_file(const std::string &filename)
Returns true if the file ends with '.gz'.
static bool file_exists(const bfs::path &fpath)
std::unique_ptr< SDL_RWops, sdl_rwops_deleter > rwops_ptr
std::string get_exe_dir()
bool is_legal_user_file_name(const std::string &name, bool allow_whitespace=true)
Returns whether the given filename is a legal name for a user-created file.
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
bool delete_directory(const std::string &dirname, const bool keep_pbl)
std::string get_synced_prefs_file()
location of preferences file containing preferences that are synced between computers note that wesno...
utils::optional< std::string > get_wml_location(const std::string &path, const utils::optional< std::string > ¤t_dir)
Returns a translated path to the actual file or directory, if it exists.
std::string get_saves_dir()
rwops_ptr make_read_RWops(const std::string &path)
const file_tree_checksum & data_tree_checksum(bool reset=false)
Get the time at which the data/ tree was last modified at.
std::string get_program_invocation(const std::string &program_name)
Returns the appropriate invocation for a Wesnoth-related binary, assuming that it is located in the s...
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
std::string get_unsynced_prefs_file()
location of preferences file containing preferences that aren't synced between computers
std::string get_save_index_file()
const std::string map_extension
bool is_compressed_file(const std::string &filename)
utils::optional< 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, if it exists.
filesystem::scoped_ostream ostream_file(const std::string &fname, std::ios_base::openmode mode, bool create_directory)
static bool create_directory_if_missing_recursive(const bfs::path &dirpath)
int file_size(const std::string &fname)
Returns the size of a file, or -1 if the file doesn't exist.
bool is_mask(const std::string &filename)
Returns true if the file ends with the maskfile extension.
utils::optional< std::string > get_addon_id_from_path(const std::string &location)
Returns the add-on ID from a path.
std::string get_lua_history_file()
std::string autodetect_game_data_dir(std::string exe_dir)
Try to autodetect the location of the game data dir.
std::string read_file_as_data_uri(const std::string &fname)
void set_cache_dir(const std::string &newcachedir)
std::string read_scenario(const std::string &name)
const std::string mask_extension
std::unique_ptr< std::istream > scoped_istream
void clear_binary_paths_cache()
std::string get_screenshot_dir()
std::string get_credentials_file()
void write_file(const std::string &fname, const std::string &data, std::ios_base::openmode mode)
Throws io_exception if an error occurs.
std::string get_short_wml_path(const std::string &filename)
Returns a short path to filename, skipping the (user) data directory.
std::string root_name(const std::string &path)
Returns the name of the root device if included in the given path.
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.
std::string get_logs_dir()
std::unique_ptr< std::ostream > scoped_ostream
static bool create_directory_if_missing(const bfs::path &dirpath)
utils::optional< 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, if it exists.
bool is_userdata_initialized()
std::string nearest_extant_parent(const std::string &file)
Finds the nearest parent in existence for a file or directory.
char path_separator()
Returns the standard path separator for the current platform.
std::string get_sync_dir()
parent directory for everything that should be synced between systems.
bool looks_like_pbl(const std::string &file)
std::string get_addons_data_dir()
bool is_map(const std::string &filename)
Returns true if the file ends with the mapfile extension.
bool make_directory(const std::string &dirname)
utils::optional< std::string > get_independent_binary_file_path(const std::string &type, const std::string &filename)
Returns an asset path to filename for binary path-independent use in saved games.
std::string get_wesnothd_name()
std::string get_default_prefs_file()
bool to_asset_path(std::string &path, std::string addon_id, std::string asset_type)
Helper function to convert absolute path to wesnoth relative path.
const blacklist_pattern_list default_blacklist
std::string get_addons_dir()
bool set_cwd(const std::string &dir)
utils::optional< std::string > get_localized_path(const std::string &file, const std::string &suff)
Returns the localized version of the given filename, if it exists.
std::vector< other_version_dir > find_other_version_saves_dirs()
Searches for directories containing saves created by other versions of Wesnoth.
rwops_ptr make_write_RWops(const std::string &path)
std::string get_next_filename(const std::string &name, const std::string &extension)
Get the next free filename using "name + number (3 digits) + extension" maximum 1000 files then start...
std::string get_intl_dir()
std::string get_core_images_dir()
std::vector< uint8_t > read_file_binary(const std::string &fname)
std::string sanitize_path(const std::string &path)
Sanitizes a path to remove references to the user's name.
std::string get_current_editor_dir(const std::string &addon_id)
const std::string get_version_path_suffix(const version_info &version)
bool is_path_sep(char c)
Returns whether c is a path separator.
std::string read_map(const std::string &name)
std::string normalize_path(const std::string &fpath, bool normalize_separators, bool resolve_dot_entries)
Returns the absolute path of a file.
void set_user_data_dir(std::string newprefdir)
const std::vector< std::string > & get_binary_paths(const std::string &type)
Returns a vector with all possible paths to a given type of binary, e.g.
Game configuration data as global variables.
std::string default_preferences_path
const std::string observer_team_name
observer team name used for observer team chat
int cache_compression_level
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
rect src
Non-transparent portion of the surface to compose.
std::string filename
Filename.
The paths manager is responsible for recording the various paths that binary files may be located at.
std::vector< std::string > paths_
binary_paths_manager(const binary_paths_manager &o)
binary_paths_manager & operator=(const binary_paths_manager &o)
void set_paths(const game_config_view &cfg)
void write(config &cfg) const
bool operator==(const file_tree_checksum &rhs) const
bool operator!=(const file_tree_checksum &rhs) const
An exception object used when an IO error occurs.
io_exception(const std::string &msg)
std::string version
Here the version is given as a string instead of a version_info, because the logic of how many compon...
other_version_dir(const std::string &v, const std::string &p)
void operator()(SDL_RWops *) const noexcept
Base class for all the errors encountered by the engine.