20 #ifndef FILESYSTEM_HPP_INCLUDED
21 #define FILESYSTEM_HPP_INCLUDED
45 struct file_tree_checksum;
62 std::vector<std::string>* files,
63 std::vector<std::string>* dirs=
nullptr,
67 file_tree_checksum* checksum =
nullptr);
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...
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...
void set_user_data_dir(std::string path)
void set_paths(const config &cfg)
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...
bool delete_file(const std::string &filename)
bool looks_like_pbl(const std::string &file)
scoped_istream & operator=(std::istream *)
std::istream & operator*()
GLuint GLuint GLsizei GLenum type
bool ends_with(const std::string &str, const std::string &suffix)
The paths manager is responsible for recording the various paths that binary files may be located at...
std::string get_screenshot_dir()
scoped_ostream(std::ostream *s)
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...
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
std::string get_saves_dir()
io_exception(const std::string &msg)
void clear_binary_paths_cache()
GLsizei const char ** path
bool create_directory_if_missing_recursive(const std::string &dirname)
Creates a recursive directory tree if it does not exist already.
bool create_directory_if_missing(const std::string &dirname)
Creates a directory if it does not exist already.
std::string get_user_data_dir()
std::string get_intl_dir()
std::string normalize_path(const std::string &path)
Returns the absolute path of a file.
void write_file(const std::string &fname, const std::string &data)
Throws io_exception if an error occurs.
std::istream * operator->()
std::string base_name(const std::string &file)
Returns the base filename of a file, with directory name stripped.
std::istream * istream_file(const std::string &fname, bool treat_failure_as_error=true)
scoped_ostream & operator=(std::ostream *)
std::ostream * ostream_file(std::string const &fname, bool create_directory=true)
bool is_directory(const std::string &fname)
Returns true if the given file is a directory.
std::string get_short_wml_path(const std::string &filename)
Returns a short path to filename, skipping the (user) data 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. ...
std::string get_dir(const std::string &dir)
std::string get_default_prefs_file()
std::string read_file(const std::string &fname)
Basic disk I/O - read file.
std::string read_map(const std::string &name)
bool is_path_sep(char c)
Returns whether c is a path separator.
bool is_gzip_file(const std::string &filename)
Returns true if the file ends with '.gz'.
std::string get_cache_dir()
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.
time_t file_modified_time(const std::string &fname)
Get the modification time of a file.
std::string get_exe_dir()
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.
int dir_size(const std::string &path)
Returns the sum of the sizes of the files contained in a directory.
void set_user_config_dir(std::string path)
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...
std::vector< std::string > paths_
An exception object used when an IO error occurs.
bool make_directory(const std::string &dirname)
bool is_compressed_file(const std::string &filename)
void write(config &cfg) const
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
bool operator!=(const file_tree_checksum &rhs) const
bool delete_directory(const std::string &dirname, const bool keep_pbl=false)
const file_tree_checksum & data_tree_checksum(bool reset=false)
Get the time at which the data/ tree was last modified at.
int file_size(const std::string &fname)
Returns the size of a file, or -1 if the file doesn't exist.
GLuint const GLchar * name
std::ostream * operator->()
std::string get_user_config_dir()
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
bool is_bzip2_file(const std::string &filename)
Returns true if the file ends with '.bz2'.
Base class for all the errors encountered by the engine.
std::string get_addons_dir()
std::ostream & operator*()
binary_paths_manager & operator=(const binary_paths_manager &o)
SDL_RWops * load_RWops(const std::string &path)
std::string get_prefs_file()
A config object defines a single node in a WML file, with access to child nodes.
bool operator==(const file_tree_checksum &rhs) const
std::string get_save_index_file()
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
scoped_istream(std::istream *s)
GLsizei const GLcharARB ** string
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.