The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Namespaces | Enumerations | Functions
filesystem.hpp File Reference

Declarations for File-IO. More...

#include <time.h>
#include <iosfwd>
#include <string>
#include <vector>
#include "exceptions.hpp"
Include dependency graph for filesystem.hpp:

Go to the source code of this file.

Classes

struct  filesystem::io_exception
 An exception object used when an IO error occurs. More...
 
struct  filesystem::file_tree_checksum
 
struct  filesystem::binary_paths_manager
 The paths manager is responsible for recording the various paths that binary files may be located at. More...
 
class  filesystem::scoped_istream
 
class  filesystem::scoped_ostream
 

Namespaces

 filesystem
 

Enumerations

enum  filesystem::file_name_option { filesystem::ENTIRE_FILE_PATH, filesystem::FILE_NAME_ONLY }
 
enum  filesystem::file_filter_option { filesystem::NO_FILTER, filesystem::SKIP_MEDIA_DIR, filesystem::SKIP_PBL_FILES }
 
enum  filesystem::file_reorder_option { filesystem::DONT_REORDER, filesystem::DO_REORDER }
 

Functions

SDL_RWops * filesystem::load_RWops (const std::string &path)
 
void filesystem::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. More...
 
std::string filesystem::get_dir (const std::string &dir)
 
std::string filesystem::get_prefs_file ()
 
std::string filesystem::get_default_prefs_file ()
 
std::string filesystem::get_save_index_file ()
 
std::string filesystem::get_saves_dir ()
 
std::string filesystem::get_intl_dir ()
 
std::string filesystem::get_screenshot_dir ()
 
std::string filesystem::get_addons_dir ()
 
std::string filesystem::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 always giving 999. More...
 
void filesystem::set_user_config_dir (std::string path)
 
void filesystem::set_user_data_dir (std::string path)
 
std::string filesystem::get_user_config_dir ()
 
std::string filesystem::get_user_data_dir ()
 
std::string filesystem::get_cache_dir ()
 
std::string filesystem::get_cwd ()
 
std::string filesystem::get_exe_dir ()
 
bool filesystem::make_directory (const std::string &dirname)
 
bool filesystem::delete_directory (const std::string &dirname, const bool keep_pbl=false)
 
bool filesystem::delete_file (const std::string &filename)
 
bool filesystem::looks_like_pbl (const std::string &file)
 
std::string filesystem::read_file (const std::string &fname)
 Basic disk I/O - read file. More...
 
std::istream * filesystem::istream_file (const std::string &fname, bool treat_failure_as_error=true)
 
std::ostream * filesystem::ostream_file (std::string const &fname, bool create_directory=true)
 
void filesystem::write_file (const std::string &fname, const std::string &data)
 Throws io_exception if an error occurs. More...
 
std::string filesystem::read_map (const std::string &name)
 
bool filesystem::create_directory_if_missing (const std::string &dirname)
 Creates a directory if it does not exist already. More...
 
bool filesystem::create_directory_if_missing_recursive (const std::string &dirname)
 Creates a recursive directory tree if it does not exist already. More...
 
bool filesystem::is_directory (const std::string &fname)
 Returns true if the given file is a directory. More...
 
bool filesystem::file_exists (const std::string &name)
 Returns true if a file or directory with such name already exists. More...
 
time_t filesystem::file_modified_time (const std::string &fname)
 Get the modification time of a file. More...
 
bool filesystem::is_gzip_file (const std::string &filename)
 Returns true if the file ends with '.gz'. More...
 
bool filesystem::is_bzip2_file (const std::string &filename)
 Returns true if the file ends with '.bz2'. More...
 
bool filesystem::is_compressed_file (const std::string &filename)
 
const file_tree_checksum & filesystem::data_tree_checksum (bool reset=false)
 Get the time at which the data/ tree was last modified at. More...
 
int filesystem::file_size (const std::string &fname)
 Returns the size of a file, or -1 if the file doesn't exist. More...
 
int filesystem::dir_size (const std::string &path)
 Returns the sum of the sizes of the files contained in a directory. More...
 
bool filesystem::ends_with (const std::string &str, const std::string &suffix)
 
std::string filesystem::base_name (const std::string &file)
 Returns the base filename of a file, with directory name stripped. More...
 
std::string filesystem::directory_name (const std::string &file)
 Returns the directory name of a file, with filename stripped. More...
 
std::string filesystem::normalize_path (const std::string &path)
 Returns the absolute path of a file. More...
 
bool filesystem::is_path_sep (char c)
 Returns whether c is a path separator. More...
 
void filesystem::clear_binary_paths_cache ()
 
const std::vector< std::string > & filesystem::get_binary_paths (const std::string &type)
 Returns a vector with all possible paths to a given type of binary, e.g. More...
 
std::string filesystem::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 present. More...
 
std::string filesystem::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 isn't present. More...
 
std::string filesystem::get_wml_location (const std::string &filename, const std::string &current_dir=std::string())
 Returns a complete path to the actual WML file or directory or an empty string if the file isn't present. More...
 
std::string filesystem::get_short_wml_path (const std::string &filename)
 Returns a short path to filename, skipping the (user) data directory. More...
 
std::string filesystem::get_independent_image_path (const std::string &filename)
 Returns an image path to filename for binary path-independent use in saved games. More...
 
std::string filesystem::get_program_invocation (const std::string &program_name)
 Returns the appropriate invocation for a Wesnoth-related binary, assuming that it is located in the same directory as the running wesnoth binary. More...
 

Detailed Description

Declarations for File-IO.

Definition in file filesystem.hpp.