File-IO. More...
#include "filesystem.hpp"
#include "config.hpp"
#include "deprecation.hpp"
#include "game_config.hpp"
#include "game_version.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "serialization/string_utils.hpp"
#include "serialization/unicode.hpp"
#include "serialization/unicode_cast.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include "game_config_view.hpp"
#include <algorithm>
#include <set>
Go to the source code of this file.
Namespaces | |
filesystem | |
Macros | |
#define | GETTEXT_DOMAIN "wesnoth-lib" |
#define | DBG_FS LOG_STREAM(debug, log_filesystem) |
#define | LOG_FS LOG_STREAM(info, log_filesystem) |
#define | WRN_FS LOG_STREAM(warn, log_filesystem) |
#define | ERR_FS LOG_STREAM(err, log_filesystem) |
Functions | |
static void | filesystem::push_if_exists (std::vector< std::string > *vec, const bfs::path &file, bool full) |
static bool | filesystem::error_except_not_found (const error_code &ec) |
static bool | filesystem::is_directory_internal (const bfs::path &fpath) |
static bool | filesystem::file_exists (const bfs::path &fpath) |
static bfs::path | filesystem::get_dir (const bfs::path &dirpath) |
static bool | filesystem::create_directory_if_missing (const bfs::path &dirpath) |
static bool | filesystem::create_directory_if_missing_recursive (const bfs::path &dirpath) |
void | filesystem::get_files_in_dir (const std::string &dir, std::vector< std::string > *files, std::vector< std::string > *dirs=nullptr, name_mode mode=name_mode::FILE_NAME_ONLY, filter_mode filter=filter_mode::NO_FILTER, reorder_mode reorder=reorder_mode::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_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... | |
static const std::string | filesystem::get_version_path_suffix (const version_info &version) |
static const std::string & | filesystem::get_version_path_suffix () |
static void | filesystem::setup_user_data_dir () |
void | filesystem::set_user_data_dir (std::string newprefdir) |
static void | filesystem::set_user_config_path (bfs::path newconfig) |
void | filesystem::set_user_config_dir (const std::string &newconfigdir) |
static const bfs::path & | filesystem::get_user_data_path () |
std::string | filesystem::get_user_config_dir () |
std::string | filesystem::get_user_data_dir () |
std::string | filesystem::get_cache_dir () |
std::vector< other_version_dir > | filesystem::find_other_version_saves_dirs () |
Searches for directories containing saves created by other versions of Wesnoth. More... | |
std::string | filesystem::get_cwd () |
bool | filesystem::set_cwd (const std::string &dir) |
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) |
bool | filesystem::delete_file (const std::string &filename) |
std::string | filesystem::read_file (const std::string &fname) |
Basic disk I/O - read file. More... | |
filesystem::scoped_istream | filesystem::istream_file (const std::string &fname, bool treat_failure_as_error) |
filesystem::scoped_ostream | filesystem::ostream_file (const std::string &fname, bool create_directory) |
void | filesystem::write_file (const std::string &fname, const std::string &data) |
Throws io_exception if an error occurs. More... | |
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... | |
std::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... | |
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... | |
std::string | filesystem::base_name (const std::string &file, const bool remove_extension=false) |
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::nearest_extant_parent (const std::string &file) |
Finds the nearest parent in existence for a file or directory. More... | |
bool | filesystem::is_path_sep (char c) |
Returns whether c is a path separator. More... | |
char | filesystem::path_separator () |
Returns the standard path separator for the current platform. More... | |
bool | filesystem::is_root (const std::string &path) |
Returns whether the path is the root of the file hierarchy. More... | |
std::string | filesystem::root_name (const std::string &path) |
Returns the name of the root device if included in the given path. More... | |
bool | filesystem::is_relative (const std::string &path) |
Returns whether the path seems to be relative. More... | |
std::string | filesystem::normalize_path (const std::string &path, bool normalize_separators=false, bool resolve_dot_entries=false) |
Returns the absolute path of a file. More... | |
static void | filesystem::init_binary_paths () |
void | filesystem::clear_binary_paths_cache () |
static bool | filesystem::is_legal_file (const std::string &filename_str) |
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 ¤t_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... | |
static bfs::path | filesystem::subtract_path (const bfs::path &full, const bfs::path &prefix) |
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... | |
std::string | filesystem::sanitize_path (const std::string &path) |
Sanitizes a path to remove references to the user's name. More... | |
std::string | filesystem::get_localized_path (const std::string &file, const std::string &suff="") |
Returns the localized version of the given filename, if it exists. More... | |
Variables | |
static lg::log_domain | log_filesystem ("filesystem") |
static bfs::path | filesystem::user_data_dir |
static bfs::path | filesystem::user_config_dir |
static bfs::path | filesystem::cache_dir |
File-IO.
Definition in file filesystem.cpp.
#define DBG_FS LOG_STREAM(debug, log_filesystem) |
#define ERR_FS LOG_STREAM(err, log_filesystem) |
Definition at line 72 of file filesystem.cpp.
Referenced by filesystem::create_directory_if_missing(), filesystem::create_directory_if_missing_recursive(), filesystem::delete_file(), filesystem::file_exists(), filesystem::get_binary_paths(), filesystem::get_cwd(), filesystem::get_dir(), filesystem::is_legal_file(), filesystem::istream_file(), filesystem::make_directory(), filesystem::set_cwd(), filesystem::binary_paths_manager::set_paths(), filesystem::set_user_config_path(), filesystem::set_user_data_dir(), and filesystem::setup_user_data_dir().
#define GETTEXT_DOMAIN "wesnoth-lib" |
Definition at line 19 of file filesystem.cpp.
#define LOG_FS LOG_STREAM(info, log_filesystem) |
Definition at line 70 of file filesystem.cpp.
Referenced by filesystem::delete_directory(), filesystem::dir_size(), filesystem::file_modified_time(), filesystem::file_size(), filesystem::get_files_in_dir(), filesystem::is_directory_internal(), filesystem::is_legal_file(), filesystem::istream_file(), filesystem::ostream_file(), and filesystem::set_cwd().
#define WRN_FS LOG_STREAM(warn, log_filesystem) |
Definition at line 71 of file filesystem.cpp.
Referenced by filesystem::get_binary_file_location().
|
static |