42 typedef std::unique_ptr<SDL_RWops, void(*)(SDL_RWops*)>
rwops_ptr;
64 : file_patterns_(), directory_patterns_()
66 blacklist_pattern_list(
const std::vector<std::string>& file_patterns,
const std::vector<std::string>& directory_patterns)
67 : file_patterns_(file_patterns), directory_patterns_(directory_patterns)
70 bool match_file(
const std::string& name)
const;
72 bool match_dir(
const std::string& name)
const;
76 file_patterns_.push_back(pattern);
81 directory_patterns_.push_back(pattern);
84 void remove_blacklisted_files_and_dirs(std::vector<std::string>& files, std::vector<std::string>& directories)
const;
137 std::vector<std::string>* files,
138 std::vector<std::string>* dirs=
nullptr,
144 std::string
get_dir(
const std::string &dir);
162 std::string
get_next_filename(
const std::string& name,
const std::string& extension);
200 bool set_cwd(
const std::string& dir);
205 bool delete_directory(
const std::string& dirname,
const bool keep_pbl =
false);
213 std::string
read_file(
const std::string& fname);
217 void write_file(
const std::string& fname,
const std::string&
data, std::ios_base::openmode mode = std::ios_base::binary);
224 void copy_file(
const std::string& src,
const std::string& dest);
226 std::string
read_map(
const std::string& name);
281 void reset() {nfiles = 0;modified = 0;sum_size=0;}
297 int dir_size(
const std::string& path);
299 bool ends_with(
const std::string& str,
const std::string& suffix);
308 std::string
base_name(
const std::string& file,
const bool remove_extension =
false);
346 bool normalize_separators =
false,
347 bool resolve_dot_entries =
false);
360 bool is_root(
const std::string& path);
370 std::string
root_name(
const std::string& path);
444 const std::string ¤t_dir = std::string());
472 std::string
get_localized_path(
const std::string& file,
const std::string& suff =
"");
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...
bool delete_directory(const std::string &dirname, const bool keep_pbl)
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...
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.
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...
Interfaces for manipulating version numbers of engine, add-ons, etc.
bool delete_file(const std::string &filename)
static bool create_directory_if_missing(const bfs::path &dirpath)
bool looks_like_pbl(const std::string &file)
void add_directory_pattern(const std::string &pattern)
void set_user_data_dir(std::string newprefdir)
static bool file_exists(const bfs::path &fpath)
bool ends_with(const std::string &str, const std::string &suffix)
rwops_ptr make_read_RWops(const std::string &path)
filesystem::scoped_istream istream_file(const std::string &fname, bool treat_failure_as_error)
The paths manager is responsible for recording the various paths that binary files may be located at...
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)
std::string get_logs_dir()
std::string get_screenshot_dir()
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
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...
std::string normalize_path(const std::string &fpath, bool normalize_separators, bool resolve_dot_entries)
Returns the absolute path of a file.
void set_cache_dir(const std::string &newcachedir)
std::string get_saves_dir()
filesystem::scoped_ostream ostream_file(const std::string &fname, std::ios_base::openmode mode, bool create_directory)
static bfs::path get_dir(const bfs::path &dirpath)
io_exception(const std::string &msg)
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. ...
void clear_binary_paths_cache()
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
rwops_ptr make_write_RWops(const std::string &path)
std::string get_user_data_dir()
std::vector< std::string > directory_patterns_
std::string get_intl_dir()
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.
std::string root_name(const std::string &path)
Returns the name of the root device if included in the given path.
std::string nearest_extant_parent(const std::string &file)
Finds the nearest parent in existence for a file or directory.
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
std::unique_ptr< std::istream > scoped_istream
std::string get_short_wml_path(const std::string &filename)
Returns a short path to filename, skipping the (user) data directory.
std::vector< std::string > file_patterns_
std::string sanitize_path(const std::string &path)
Sanitizes a path to remove references to the user's name.
std::string get_default_prefs_file()
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
void add_file_pattern(const std::string &pattern)
std::string read_map(const std::string &name)
bool is_path_sep(char c)
Returns whether c is a path separator.
std::unique_ptr< std::ostream > scoped_ostream
bool is_gzip_file(const std::string &filename)
Returns true if the file ends with '.gz'.
std::string get_cache_dir()
void write_file(const std::string &fname, const std::string &data, std::ios_base::openmode mode)
Throws io_exception if an error occurs.
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.
std::string get_exe_dir()
bool is_relative(const std::string &path)
Returns whether the path seems to be relative.
void set_user_config_dir(const std::string &newconfigdir)
int dir_size(const std::string &pname)
Returns the sum of the sizes of the files contained in a directory.
std::string get_wml_location(const std::string &filename, const std::string ¤t_dir)
Returns a complete path to the actual WML file or directory or an empty string if the file isn't pres...
std::vector< std::string > paths_
void copy_file(const std::string &src, const std::string &dest)
Read a file and then writes it back out.
An exception object used when an IO error occurs.
bool operator==(const config &a, const config &b)
bool make_directory(const std::string &dirname)
bool is_compressed_file(const std::string &filename)
bool is_root(const std::string &path)
Returns whether the path is the root of the file hierarchy.
std::unique_ptr< SDL_RWops, void(*)(SDL_RWops *)> rwops_ptr
std::string get_localized_path(const std::string &file, const std::string &suff)
Returns the localized version of the given filename, if it exists.
Represents version numbers.
const file_tree_checksum & data_tree_checksum(bool reset=false)
Get the time at which the data/ tree was last modified at.
char path_separator()
Returns the standard path separator for the current platform.
std::string base_name(const std::string &file, const bool remove_extension)
Returns the base filename of a file, with directory name stripped.
int file_size(const std::string &fname)
Returns the size of a file, or -1 if the file doesn't exist.
const std::string get_version_path_suffix(const version_info &version)
bool set_cwd(const std::string &dir)
std::string get_user_config_dir()
bool is_bzip2_file(const std::string &filename)
Returns true if the file ends with '.bz2'.
std::time_t file_modified_time(const std::string &fname)
Get the modification time of a file.
Base class for all the errors encountered by the engine.
std::string get_addons_dir()
std::string get_credentials_file()
bool operator!=(const file_tree_checksum &rhs) const
blacklist_pattern_list(const std::vector< std::string > &file_patterns, const std::vector< std::string > &directory_patterns)
std::vector< other_version_dir > find_other_version_saves_dirs()
Searches for directories containing saves created by other versions of Wesnoth.
std::string get_prefs_file()
A config object defines a single node in a WML file, with access to child nodes.
std::string get_save_index_file()
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.
static bool create_directory_if_missing_recursive(const bfs::path &dirpath)
static const blacklist_pattern_list default_blacklist