Classes | |
struct | sdl_rwops_deleter |
struct | io_exception |
An exception object used when an IO error occurs. More... | |
class | blacklist_pattern_list |
struct | other_version_dir |
struct | file_tree_checksum |
struct | binary_paths_manager |
The paths manager is responsible for recording the various paths that binary files may be located at. More... | |
class | atomic_commit |
Wrapper class that guarantees that file commit atomicity. More... | |
Typedefs | |
using | scoped_istream = std::unique_ptr< std::istream > |
using | scoped_ostream = std::unique_ptr< std::ostream > |
using | rwops_ptr = std::unique_ptr< SDL_RWops, sdl_rwops_deleter > |
typedef std::pair< int64_t, std::ios_base::seekdir > | offset_dir |
Enumerations | |
enum class | name_mode { ENTIRE_FILE_PATH , FILE_NAME_ONLY } |
enum class | filter_mode { NO_FILTER , SKIP_MEDIA_DIR , SKIP_PBL_FILES } |
enum class | reorder_mode { DONT_REORDER , DO_REORDER } |
Functions | |
static void | push_if_exists (std::vector< std::string > *vec, const bfs::path &file, bool full) |
static bool | error_except_not_found (const error_code &ec) |
static bool | is_directory_internal (const bfs::path &fpath) |
static bool | file_exists (const bfs::path &fpath) |
static bfs::path | get_dir (const bfs::path &dirpath) |
static bool | create_directory_if_missing (const bfs::path &dirpath) |
static bool | create_directory_if_missing_recursive (const bfs::path &dirpath) |
void | 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) |
Get a list of all files and/or directories in a given directory. More... | |
std::string | get_dir (const std::string &dir) |
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 always giving 999. More... | |
const std::string | get_version_path_suffix (const version_info &version) |
const std::string & | get_version_path_suffix () |
static void | setup_user_data_dir () |
void | set_user_data_dir (std::string newprefdir) |
static void | set_user_config_path (bfs::path newconfig) |
void | set_user_config_dir (const std::string &newconfigdir) |
static void | set_cache_path (bfs::path newcache) |
void | set_cache_dir (const std::string &newcachedir) |
static const bfs::path & | get_user_data_path () |
std::string | get_user_config_dir () |
std::string | get_user_data_dir () |
std::string | get_logs_dir () |
std::string | get_cache_dir () |
std::vector< other_version_dir > | find_other_version_saves_dirs () |
Searches for directories containing saves created by other versions of Wesnoth. More... | |
std::string | get_cwd () |
bool | set_cwd (const std::string &dir) |
std::string | get_exe_dir () |
bool | make_directory (const std::string &dirname) |
bool | delete_directory (const std::string &dirname, const bool keep_pbl) |
bool | delete_file (const std::string &filename) |
std::string | read_file (const std::string &fname) |
Basic disk I/O - read file. More... | |
filesystem::scoped_istream | istream_file (const std::string &fname, bool treat_failure_as_error) |
filesystem::scoped_ostream | ostream_file (const std::string &fname, std::ios_base::openmode mode, bool create_directory) |
void | write_file (const std::string &fname, const std::string &data, std::ios_base::openmode mode=std::ios_base::binary) |
Throws io_exception if an error occurs. More... | |
void | copy_file (const std::string &src, const std::string &dest) |
Read a file and then writes it back out. More... | |
bool | create_directory_if_missing (const std::string &dirname) |
Creates a directory if it does not exist already. More... | |
bool | create_directory_if_missing_recursive (const std::string &dirname) |
Creates a recursive directory tree if it does not exist already. More... | |
bool | is_directory (const std::string &fname) |
Returns true if the given file is a directory. More... | |
bool | file_exists (const std::string &name) |
Returns true if a file or directory with such name already exists. More... | |
std::time_t | file_modified_time (const std::string &fname) |
Get the modification time of a file. More... | |
bool | is_gzip_file (const std::string &filename) |
Returns true if the file ends with '.gz'. More... | |
bool | is_bzip2_file (const std::string &filename) |
Returns true if the file ends with '.bz2'. More... | |
int | file_size (const std::string &fname) |
Returns the size of a file, or -1 if the file doesn't exist. More... | |
int | dir_size (const std::string &path) |
Returns the sum of the sizes of the files contained in a directory. More... | |
std::string | 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 | directory_name (const std::string &file) |
Returns the directory name of a file, with filename stripped. More... | |
std::string | nearest_extant_parent (const std::string &file) |
Finds the nearest parent in existence for a file or directory. More... | |
bool | is_path_sep (char c) |
Returns whether c is a path separator. More... | |
char | path_separator () |
Returns the standard path separator for the current platform. More... | |
bool | is_root (const std::string &path) |
Returns whether the path is the root of the file hierarchy. More... | |
std::string | root_name (const std::string &path) |
Returns the name of the root device if included in the given path. More... | |
bool | is_relative (const std::string &path) |
Returns whether the path seems to be relative. More... | |
std::string | 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 | init_binary_paths () |
void | clear_binary_paths_cache () |
static bool | is_legal_file (const std::string &filename_str) |
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. More... | |
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 present. More... | |
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 isn't present. More... | |
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 present. More... | |
static bfs::path | subtract_path (const bfs::path &full, const bfs::path &prefix) |
std::string | get_short_wml_path (const std::string &filename) |
Returns a short path to filename, skipping the (user) data directory. More... | |
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. More... | |
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 same directory as the running wesnoth binary. More... | |
std::string | sanitize_path (const std::string &path) |
Sanitizes a path to remove references to the user's name. More... | |
std::string | get_localized_path (const std::string &file, const std::string &suff="") |
Returns the localized version of the given filename, if it exists. More... | |
rwops_ptr | make_read_RWops (const std::string &path) |
rwops_ptr | make_write_RWops (const std::string &path) |
std::string | get_prefs_file () |
std::string | get_credentials_file () |
std::string | get_default_prefs_file () |
std::string | get_save_index_file () |
std::string | get_saves_dir () |
std::string | get_intl_dir () |
std::string | get_screenshot_dir () |
std::string | get_addons_dir () |
bool | looks_like_pbl (const std::string &file) |
std::string | read_map (const std::string &name) |
bool | is_compressed_file (const std::string &filename) |
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. More... | |
const file_tree_checksum & | data_tree_checksum (bool reset=false) |
Get the time at which the data/ tree was last modified at. More... | |
bool | ends_with (const std::string &str, const std::string &suffix) |
static void | get_file_tree_checksum_internal (const std::string &path, file_tree_checksum &res) |
static int64_t | ifs_size (struct SDL_RWops *context) |
static int64_t | ofs_size (struct SDL_RWops *context) |
static int64_t SDLCALL | ifs_seek (struct SDL_RWops *context, int64_t offset, int whence) |
static int64_t SDLCALL | ofs_seek (struct SDL_RWops *context, int64_t offset, int whence) |
static std::size_t SDLCALL | ifs_read (struct SDL_RWops *context, void *ptr, std::size_t size, std::size_t maxnum) |
static std::size_t SDLCALL | ofs_read (struct SDL_RWops *context, void *ptr, std::size_t size, std::size_t maxnum) |
static std::size_t SDLCALL | ifs_write (struct SDL_RWops *context, const void *ptr, std::size_t size, std::size_t num) |
static std::size_t SDLCALL | ofs_write (struct SDL_RWops *context, const void *ptr, std::size_t size, std::size_t num) |
static int SDLCALL | ifs_close (struct SDL_RWops *context) |
static int SDLCALL | ofs_close (struct SDL_RWops *context) |
static offset_dir | translate_seekdir (int64_t offset, int whence) |
Variables | |
const blacklist_pattern_list | default_blacklist |
static bfs::path | user_data_dir |
static bfs::path | user_config_dir |
static bfs::path | cache_dir |
static const uint32_t | read_type = 7 |
static const uint32_t | write_type = 8 |
typedef std::pair<int64_t, std::ios_base::seekdir> filesystem::offset_dir |
Definition at line 120 of file filesystem_sdl.cpp.
using filesystem::rwops_ptr = typedef std::unique_ptr<SDL_RWops, sdl_rwops_deleter> |
Definition at line 59 of file filesystem.hpp.
using filesystem::scoped_istream = typedef std::unique_ptr<std::istream> |
Definition at line 51 of file filesystem.hpp.
using filesystem::scoped_ostream = typedef std::unique_ptr<std::ostream> |
Definition at line 52 of file filesystem.hpp.
|
strong |
Enumerator | |
---|---|
NO_FILTER | |
SKIP_MEDIA_DIR | |
SKIP_PBL_FILES |
Definition at line 73 of file filesystem.hpp.
|
strong |
Enumerator | |
---|---|
ENTIRE_FILE_PATH | |
FILE_NAME_ONLY |
Definition at line 72 of file filesystem.hpp.
|
strong |
Enumerator | |
---|---|
DONT_REORDER | |
DO_REORDER |
Definition at line 74 of file filesystem.hpp.
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.
Equivalent to a portable basename() function.
If remove_extension is true, the filename extension will be stripped from the returned value.
Definition at line 1233 of file filesystem.cpp.
References game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), default_map_generator_job::default_generate_map(), game_config::config_cache::delete_cache_files(), editor::context_manager::expand_load_mru_menu(), editor::context_manager::expand_open_maps_menu(), campaignd::find_translations(), get_localized_path(), gui2::dialogs::file_dialog::on_bookmark_add_cmd(), gui2::dialogs::screenshot_notification::pre_show(), preprocess_resource(), preprocessor_file::preprocessor_file(), gui2::dialogs::file_dialog::register_new_selection(), editor::map_context::save_scenario(), gui2::dialogs::custom_tod::select_file(), gui2::dialogs::file_dialog::set_path(), editor::context_manager::set_window_title(), and unit_abilities().
void filesystem::clear_binary_paths_cache | ( | ) |
Definition at line 1416 of file filesystem.cpp.
Referenced by game_config_manager::reload_changed_game_config().
void filesystem::copy_file | ( | const std::string & | src, |
const std::string & | dest | ||
) |
Read a file and then writes it back out.
src | The source file. |
dest | The destination of the copied file. |
Definition at line 1152 of file filesystem.cpp.
References read_file(), and write_file().
Referenced by gui2::dialogs::migrate_version_selection::post_show().
|
static |
Definition at line 354 of file filesystem.cpp.
References DBG_FS, ERR_FS, error_except_not_found(), image::exists(), and is_directory().
Referenced by create_directory_if_missing(), create_directory_if_missing_recursive(), set_user_data_dir(), and setup_user_data_dir().
bool filesystem::create_directory_if_missing | ( | const std::string & | dirname | ) |
Creates a directory if it does not exist already.
dirname | Path to directory. All parents should exist. |
Definition at line 1157 of file filesystem.cpp.
References create_directory_if_missing(), and game_config::path.
|
static |
Definition at line 378 of file filesystem.cpp.
References create_directory_if_missing(), DBG_FS, ERR_FS, error_except_not_found(), image::exists(), and is_directory().
Referenced by create_directory_if_missing_recursive(), get_cache_dir(), preprocess_resource(), set_cache_path(), set_user_config_path(), and setup_user_data_dir().
bool filesystem::create_directory_if_missing_recursive | ( | const std::string & | dirname | ) |
Creates a recursive directory tree if it does not exist already.
dirname | Full path of target directory. Non existing parents will be created |
Definition at line 1162 of file filesystem.cpp.
References create_directory_if_missing_recursive(), and game_config::path.
const file_tree_checksum & filesystem::data_tree_checksum | ( | bool | reset = false | ) |
Get the time at which the data/ tree was last modified at.
Definition at line 254 of file filesystem_common.cpp.
References get_file_tree_checksum_internal(), get_user_data_dir(), LOG_FS, filesystem::file_tree_checksum::nfiles, filesystem::file_tree_checksum::reset(), and filesystem::file_tree_checksum::sum_size.
Referenced by game_config_manager::load_game_config(), game_config::config_cache::read_cache(), and game_config::config_cache::recheck_filetree_checksum().
bool filesystem::delete_directory | ( | const std::string & | dirname, |
const bool | keep_pbl | ||
) |
Definition at line 1018 of file filesystem.cpp.
References d, ENTIRE_FILE_PATH, f, get_files_in_dir(), LOG_FS, NO_FILTER, game_config::path, gui2::dialogs::tip::remove(), and SKIP_PBL_FILES.
Referenced by campaignd::server::delete_addon(), game_config::config_cache::delete_cache_files(), gui2::dialogs::file_dialog::on_file_delete_cmd(), purge_dir(), remove_local_addon(), and game_config::config_cache::write_file().
bool filesystem::delete_file | ( | const std::string & | filename | ) |
Definition at line 1057 of file filesystem.cpp.
References ERR_FS, game_config::path, and gui2::dialogs::tip::remove().
Referenced by BOOST_AUTO_TEST_CASE(), lg::check_log_dir_writable(), savegame::save_index_class::delete_game(), campaignd::server::handle_upload(), campaignd::server::load_config(), gui2::dialogs::file_dialog::on_file_delete_cmd(), purge_dir(), lg::rotate_logs(), persist_file_context::save_context(), and preferences::save_credentials().
int filesystem::dir_size | ( | const std::string & | pname | ) |
Returns the sum of the sizes of the files contained in a directory.
Definition at line 1212 of file filesystem.cpp.
References file_size(), i, LOG_FS, p, and game_config::path.
Referenced by purge_dir(), and gui2::dialogs::game_cache_options::update_cache_size_display().
std::string filesystem::directory_name | ( | const std::string & | file | ) |
Returns the directory name of a file, with filename stripped.
Equivalent to a portable dirname()
Definition at line 1242 of file filesystem.cpp.
References game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), do_gameloop(), lua_fileops::get_calling_file(), preprocessor_data::get_chunk(), get_localized_path(), preprocessor_file::init(), editor::context_manager::load_map_dialog(), editor::map_context::map_context(), gui2::dialogs::file_dialog::path(), preprocess_resource(), preprocessor_file::preprocessor_file(), gui2::dialogs::file_dialog::register_new_selection(), gui2::dialogs::custom_tod::select_file(), and preferences::show_wesnothd_server_search().
bool filesystem::ends_with | ( | const std::string & | str, |
const std::string & | suffix | ||
) |
Definition at line 218 of file filesystem_common.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), campaignd::find_translations(), get_files_in_dir(), hotkey::hotkey_base::get_name(), image::load_image_file(), gui::button::load_images(), preprocess_resource(), and image::save_image().
|
inlinestatic |
Definition at line 304 of file filesystem.cpp.
Referenced by create_directory_if_missing(), create_directory_if_missing_recursive(), file_exists(), get_files_in_dir(), and is_directory_internal().
|
static |
Definition at line 320 of file filesystem.cpp.
References ERR_FS, error_except_not_found(), and image::exists().
Referenced by ad_hoc_addon_fetch_session(), adjust_profile(), autodetect_game_data_dir(), BOOST_AUTO_TEST_CASE(), font::check_font_file(), lg::check_log_dir_writable(), savegame::save_index_class::data(), network::download(), file_exists(), get_binary_file_location(), get_files_in_dir(), unit_race::get_icon_path_stem(), get_localized_path(), hotkey::command_executor::get_menu_image(), get_next_filename(), get_wml_location(), handle_preprocess_command(), have_addon_in_vcs_tree(), have_addon_install_info(), have_addon_pbl_info(), installed_addons_and_versions(), is_addon_installed(), persist_file_context::load(), game_config_manager::load_addons_cfg(), preferences::load_credentials(), game_config_manager::load_game_config(), gui::button::load_images(), editor::map_context::map_context(), gui2::dialogs::migrate_version_selection::migrate_version_selection(), desktop::os_version(), gui2::dialogs::migrate_version_selection::post_show(), process_command_args(), wesnothd::ban_manager::read(), achievements::read_achievements_file(), game_config::config_cache::read_cache(), read_ignore_patterns(), refresh_addon_version_info_cache(), gui2::dialogs::file_dialog::register_new_selection(), remove_local_addon(), savegame::save_game_exists(), hotkey::command_executor_default::set_button_state(), gui2::dialogs::preferences_dialog::setup_hotkey_list(), setup_user_data_dir(), editor::start(), game_launcher::start_wesnothd(), and game_config::config_cache::write_file().
bool filesystem::file_exists | ( | const std::string & | name | ) |
Returns true if a file or directory with such name already exists.
Definition at line 1172 of file filesystem.cpp.
References file_exists(), and game_config::path.
std::time_t filesystem::file_modified_time | ( | const std::string & | fname | ) |
Get the modification time of a file.
Definition at line 1177 of file filesystem.cpp.
References LOG_FS, and game_config::path.
Referenced by savegame::create_save_info::operator()(), and savegame::save_index_class::rebuild().
int filesystem::file_size | ( | const std::string & | fname | ) |
Returns the size of a file, or -1 if the file doesn't exist.
Definition at line 1198 of file filesystem.cpp.
References LOG_FS, game_config::path, and utf8::size().
Referenced by lg::check_log_dir_writable(), coro_send_file_userspace(), dir_size(), get_files_in_dir(), campaignd::server::handle_request_campaign(), campaignd::server::handle_request_campaign_hash(), campaignd::server::handle_upload(), and gui2::dialogs::screenshot_notification::save_screenshot().
std::vector< other_version_dir > filesystem::find_other_version_saves_dirs | ( | ) |
Searches for directories containing saves created by other versions of Wesnoth.
The directories returned will exist, but might not contain any saves. Changes to the filesystem (by running other versions or by deleting old directories) may change the results returned by the function.
Definition at line 896 of file filesystem.cpp.
References image::exists(), get_user_data_path(), get_version_path_suffix(), game_config::min_savegame_version, game_config::path, version_info::set_major_version(), and game_config::wesnoth_version.
Referenced by gui2::dialogs::game_load::execute(), and gui2::dialogs::game_load::set_save_dir_list().
std::string filesystem::get_addons_dir | ( | ) |
Definition at line 157 of file filesystem_common.cpp.
References get_dir(), and get_user_data_dir().
Referenced by ad_hoc_addon_fetch_session(), archive_addon(), game_config::full_build_report(), gui2::dialogs::game_version::game_version(), have_addon_in_vcs_tree(), is_addon_installed(), game_config_manager::load_addons_cfg(), game_config_manager::load_game_config(), gui2::dialogs::migrate_version_selection::migrate_version_selection(), gui2::dialogs::migrate_version_selection::post_show(), purge_addon(), read_ignore_patterns(), achievements::reload(), remove_local_addon(), and unarchive_addon().
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.
Definition at line 1538 of file filesystem.cpp.
References DBG_FS, get_binary_paths(), is_directory_internal(), is_legal_file(), and game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), and init_textdomains().
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.
Definition at line 1497 of file filesystem.cpp.
References DBG_FS, file_exists(), get_binary_paths(), is_legal_file(), game_config::path, and WRN_FS.
Referenced by BOOST_AUTO_TEST_CASE(), image::exists(), image::locator::file_exists(), unit_race::get_icon_path_stem(), get_independent_binary_file_path(), editor::editor_palette< t_translation::terrain_code >::handler_members(), intf_have_asset(), sound::load_chunk(), image::load_image_file(), read_map(), and sound::music_track::resolve().
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.
'images', 'sounds', etc,
Definition at line 1461 of file filesystem.cpp.
References ERR_FS, get_user_data_dir(), init_binary_paths(), and game_config::path.
Referenced by get_binary_dir_location(), get_binary_file_location(), and image::precache_file_existence().
std::string filesystem::get_cache_dir | ( | ) |
Definition at line 867 of file filesystem.cpp.
References cache_dir, create_directory_if_missing_recursive(), get_dir(), and get_user_data_path().
Referenced by game_config::config_cache::clean_cache(), game_config::full_build_report(), game_launcher::game_launcher(), gui2::dialogs::game_version::game_version(), font::manager::manager(), process_command_args(), game_config::config_cache::purge_cache(), and game_config::config_cache::read_cache().
std::string filesystem::get_credentials_file | ( | ) |
Definition at line 132 of file filesystem_common.cpp.
References get_user_config_dir().
Referenced by preferences::load_credentials(), gui2::dialogs::migrate_version_selection::post_show(), and preferences::save_credentials().
std::string filesystem::get_cwd | ( | ) |
Definition at line 949 of file filesystem.cpp.
References ERR_FS, and game_config::path.
Referenced by autodetect_game_data_dir(), game_launcher::game_launcher(), get_exe_dir(), get_intl_dir(), main(), process_command_args(), run_campaignd(), set_user_data_dir(), and wesnoth_global_fixture::wesnoth_global_fixture().
std::string filesystem::get_default_prefs_file | ( | ) |
Definition at line 137 of file filesystem_common.cpp.
References game_config::default_preferences_path, and game_config::path.
Referenced by preferences::load_base_prefs().
|
static |
Definition at line 331 of file filesystem.cpp.
References ERR_FS, and is_directory_internal().
Referenced by editor::context_manager::context_manager(), get_addons_dir(), get_cache_dir(), get_dir(), get_persist_cfg_name(), get_saves_dir(), get_screenshot_dir(), events::menu_handler::save_map(), editor::context_manager::save_map_as_dialog(), and editor::context_manager::save_scenario_as_dialog().
std::string filesystem::get_dir | ( | const std::string & | dir | ) |
Definition at line 541 of file filesystem.cpp.
References get_dir(), and game_config::path.
std::string filesystem::get_exe_dir | ( | ) |
Definition at line 977 of file filesystem.cpp.
References image::exists(), get_cwd(), and game_config::path.
Referenced by desktop::game_paths(), main(), and preferences::show_wesnothd_server_search().
|
static |
Definition at line 243 of file filesystem_common.cpp.
References DONT_REORDER, ENTIRE_FILE_PATH, get_files_in_dir(), game_config::path, and SKIP_MEDIA_DIR.
Referenced by data_tree_checksum().
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 |
||
) |
Get a list of all files and/or directories in a given directory.
dir | The directory to examine. | |
[out] | files | The files in dir. Won't be used if nullptr. |
[out] | dirs | The directories in dir. Won't be used if nullptr. |
mode | Determines whether the entire path or just the filename is retrieved. | |
filter | Determines if we skip images and sounds directories. | |
reorder | Triggers the special handling of _main.cfg and _final.cfg. | |
[out] | checksum | Can be used to store checksum info. |
Definition at line 406 of file filesystem.cpp.
References DO_REORDER, ends_with(), ENTIRE_FILE_PATH, error_except_not_found(), file_exists(), file_size(), i, is_directory_internal(), is_relative(), LOG_FS, looks_like_pbl(), filesystem::file_tree_checksum::modified, filesystem::file_tree_checksum::nfiles, game_config::path, push_if_exists(), utf8::size(), SKIP_MEDIA_DIR, SKIP_PBL_FILES, and filesystem::file_tree_checksum::sum_size.
Referenced by archive_dir(), BOOST_AUTO_TEST_CASE(), game_config::config_cache::clean_cache(), savegame::save_index_class::clean_up_index(), ng::create_engine::create_engine(), delete_directory(), get_file_tree_checksum_internal(), savegame::save_index_class::get_saves_list(), lua_fileops::intf_read_file(), game_config_manager::load_addons_cfg(), campaignd::server::load_config(), game_config_manager::load_game_config(), gui2::dialogs::migrate_version_selection::post_show(), image::precache_file_existence_internal(), preprocess_resource(), preprocessor_file::preprocessor_file(), game_config::config_cache::purge_cache(), gui2::dialogs::file_dialog::refresh_fileview(), achievements::reload(), and lg::rotate_logs().
std::string filesystem::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.
Example: images, units/konrad-fighter.png -> data/campaigns/Heir_To_The_Throne/images/units/konrad-fighter.png
Definition at line 1630 of file filesystem.cpp.
References get_binary_file_location(), get_user_data_path(), partial, game_config::path, and subtract_path().
Referenced by BOOST_AUTO_TEST_CASE(), gui2::dialogs::game_load::display_savegame_internal(), savegame::extract_summary_from_config(), and intf_resolve_asset().
std::string filesystem::get_intl_dir | ( | ) |
Definition at line 163 of file filesystem_common.cpp.
References get_cwd(), LOCALEDIR, and game_config::path.
Referenced by test_utils::game_config_manager::game_config_manager(), init_locale(), and init_textdomains().
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.
Definition at line 1683 of file filesystem.cpp.
References _(), base_name(), directory_name(), file_exists(), and utils::split().
Referenced by sound::load_chunk(), image::load_image_file(), and sound::play_new_music().
std::string filesystem::get_logs_dir | ( | ) |
Definition at line 862 of file filesystem.cpp.
References get_user_data_dir().
Referenced by lg::check_log_dir_writable(), do_gameloop(), game_config::full_build_report(), gui2::dialogs::game_version::game_version(), lg::set_log_to_file(), and setup_user_data_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.
Definition at line 546 of file filesystem.cpp.
References file_exists().
Referenced by gui2::dialogs::make_screenshot().
std::string filesystem::get_prefs_file | ( | ) |
Definition at line 127 of file filesystem_common.cpp.
References get_user_config_dir().
Referenced by preferences::load_base_prefs(), gui2::dialogs::migrate_version_selection::post_show(), and preferences::write_preferences().
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.
This is just a string-transformation based on argv[0], so the returned program is not guaranteed to actually exist. '-debug' variants are handled correctly.
Definition at line 1651 of file filesystem.cpp.
References game_config::path, and game_config::wesnoth_program_dir.
Referenced by game_launcher::start_wesnothd().
std::string filesystem::get_save_index_file | ( | ) |
Definition at line 146 of file filesystem_common.cpp.
References get_user_data_dir().
Referenced by savegame::save_index_class::data(), and savegame::save_index_class::write_save_index().
std::string filesystem::get_saves_dir | ( | ) |
Definition at line 151 of file filesystem_common.cpp.
References get_dir(), and get_user_data_dir().
Referenced by game_config::full_build_report(), gui2::dialogs::game_version::game_version(), playsingle_controller::hotkey_handler::load_autosave(), and gui2::dialogs::mp_match_history::update_display().
std::string filesystem::get_screenshot_dir | ( | ) |
Definition at line 183 of file filesystem_common.cpp.
References get_dir(), and get_user_data_dir().
Referenced by gui2::dialogs::game_version::game_version(), and gui2::dialogs::make_screenshot().
std::string filesystem::get_short_wml_path | ( | const std::string & | filename | ) |
Returns a short path to filename, skipping the (user) data directory.
Definition at line 1613 of file filesystem.cpp.
References get_user_data_path(), partial, game_config::path, and subtract_path().
Referenced by preprocessor_file::init(), and editor::map_context::map_context().
std::string filesystem::get_user_config_dir | ( | ) |
Definition at line 828 of file filesystem.cpp.
References get_user_data_path(), set_user_config_path(), and user_config_dir.
Referenced by game_config::full_build_report(), game_launcher::game_launcher(), desktop::game_paths(), gui2::dialogs::game_version::game_version(), get_credentials_file(), get_prefs_file(), process_command_args(), and game_launcher::start_wesnothd().
std::string filesystem::get_user_data_dir | ( | ) |
Definition at line 857 of file filesystem.cpp.
References get_user_data_path().
Referenced by BOOST_AUTO_TEST_CASE(), editor::context_manager::context_manager(), ng::create_engine::create_engine(), data_tree_checksum(), game_config::full_build_report(), game_launcher::game_launcher(), desktop::game_paths(), gui2::dialogs::game_version::game_version(), get_addons_dir(), get_binary_paths(), get_logs_dir(), get_persist_cfg_name(), get_save_index_file(), get_saves_dir(), get_screenshot_dir(), ng::create_engine::init_all_levels(), process_command_args(), read_map(), events::menu_handler::save_map(), and display::update_fps_label().
|
static |
Definition at line 819 of file filesystem.cpp.
References set_user_data_dir(), and user_data_dir.
Referenced by find_other_version_saves_dirs(), get_cache_dir(), get_independent_binary_file_path(), get_short_wml_path(), get_user_config_dir(), get_user_data_dir(), and get_wml_location().
const std::string & filesystem::get_version_path_suffix | ( | ) |
Definition at line 576 of file filesystem.cpp.
References get_version_path_suffix(), and game_config::wesnoth_version.
const std::string filesystem::get_version_path_suffix | ( | const version_info & | version | ) |
Definition at line 569 of file filesystem.cpp.
References version_info::major_version(), version_info::minor_version(), and s.
Referenced by find_other_version_saves_dirs(), get_version_path_suffix(), gui2::dialogs::migrate_version_selection::migrate_version_selection(), gui2::dialogs::migrate_version_selection::post_show(), and set_user_data_dir().
std::string filesystem::get_wml_location | ( | const std::string & | filename, |
const std::string & | current_dir | ||
) |
Returns a complete path to the actual WML file or directory or an empty string if the file isn't present.
Definition at line 1558 of file filesystem.cpp.
References DBG_FS, file_exists(), get_user_data_path(), is_legal_file(), and game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), get_addon_pbl_info(), preprocessor_data::get_chunk(), ai::configuration::get_side_config_from_file(), gui2::init(), lua_wml::intf_load_wml(), lua_wml::intf_parse_wml(), game_config_manager::load_addons_cfg(), font::load_font_config(), game_config_manager::load_game_config(), load_language_list(), editor::map_context::map_context(), process_command_args(), read_map(), lua_fileops::resolve_filename(), and game_launcher::start_wesnothd().
|
static |
Definition at line 204 of file filesystem_sdl.cpp.
Referenced by make_read_RWops().
|
static |
Definition at line 170 of file filesystem_sdl.cpp.
References utf8::size().
Referenced by make_read_RWops().
|
static |
Definition at line 135 of file filesystem_sdl.cpp.
References translate_seekdir().
Referenced by make_read_RWops().
|
static |
Definition at line 95 of file filesystem_sdl.cpp.
Referenced by make_read_RWops().
|
static |
Definition at line 188 of file filesystem_sdl.cpp.
Referenced by make_read_RWops().
|
static |
Definition at line 1363 of file filesystem.cpp.
Referenced by get_binary_paths(), and filesystem::binary_paths_manager::set_paths().
bool filesystem::is_bzip2_file | ( | const std::string & | filename | ) |
Returns true if the file ends with '.bz2'.
Definition at line 1193 of file filesystem.cpp.
References game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), is_compressed_file(), process_command_args(), and savegame::read_save_file().
|
inline |
Definition at line 245 of file filesystem.hpp.
References is_bzip2_file(), and is_gzip_file().
Referenced by BOOST_AUTO_TEST_CASE(), and savegame::savegame::check_filename().
bool filesystem::is_directory | ( | const std::string & | fname | ) |
Returns true if the given file is a directory.
Definition at line 1167 of file filesystem.cpp.
References is_directory_internal(), and game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), create_directory_if_missing(), create_directory_if_missing_recursive(), lua_fileops::intf_have_file(), lua_fileops::intf_read_file(), is_directory_internal(), persist_file_context::load(), editor::map_context::map_context(), gui2::dialogs::file_dialog::on_file_delete_cmd(), image::precache_file_existence_internal(), preprocess_resource(), process_command_args(), purge_dir(), gui2::dialogs::file_dialog::register_new_selection(), run_campaignd(), editor::context_manager::save_all_maps(), editor::context_manager::save_map(), gui2::dialogs::file_dialog::set_path(), preferences::show_wesnothd_server_search(), and editor::start().
|
static |
Definition at line 309 of file filesystem.cpp.
References error_except_not_found(), is_directory(), and LOG_FS.
Referenced by get_binary_dir_location(), get_dir(), get_files_in_dir(), and is_directory().
bool filesystem::is_gzip_file | ( | const std::string & | filename | ) |
Returns true if the file ends with '.gz'.
Definition at line 1188 of file filesystem.cpp.
References game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), is_compressed_file(), process_command_args(), and savegame::read_save_file().
|
static |
Definition at line 1421 of file filesystem.cpp.
References DBG_FS, default_blacklist, ERR_FS, LOG_FS, filesystem::blacklist_pattern_list::match_file(), and game_config::path.
Referenced by get_binary_dir_location(), get_binary_file_location(), and get_wml_location().
bool filesystem::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.
This is meant to be used for any files created by Wesnoth where user input is required, including save files and add-on files for uploading to the add-ons server.
name | File name to verify. |
allow_whitespace | Whether whitespace should be allowed. |
Definition at line 34 of file filesystem_common.cpp.
References c.
Referenced by addon_filename_legal(), and savegame::savegame::check_filename().
bool filesystem::is_path_sep | ( | char | c | ) |
Returns whether c is a path separator.
Definition at line 1267 of file filesystem.cpp.
References c, game_config::path, and s.
bool filesystem::is_relative | ( | const std::string & | path | ) |
Returns whether the path seems to be relative.
Definition at line 1317 of file filesystem.cpp.
References game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), get_files_in_dir(), and gui2::dialogs::file_dialog::register_new_selection().
bool filesystem::is_root | ( | const std::string & | path | ) |
Returns whether the path is the root of the file hierarchy.
Definition at line 1279 of file filesystem.cpp.
References p, and game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), gui2::dialogs::file_dialog::get_filelist_selection(), nearest_extant_parent(), gui2::dialogs::file_dialog::refresh_fileview(), and gui2::dialogs::file_dialog::register_new_selection().
filesystem::scoped_istream filesystem::istream_file | ( | const std::string & | fname, |
bool | treat_failure_as_error | ||
) |
Definition at line 1076 of file filesystem.cpp.
References ERR_FS, LOG_FS, game_config::path, and s.
Referenced by coro_send_file_userspace(), savegame::save_index_class::data(), savegame::find_save_file(), get_addon_install_info(), get_addon_pbl_info(), handle_preprocess_command(), campaignd::server::handle_request_campaign(), campaignd::server::handle_upload(), preprocessor_file::init(), game_launcher::init_lua_script(), lua_fileops::intf_read_file(), persist_file_context::load(), preferences::load_base_prefs(), campaignd::server::load_blacklist(), campaignd::server::load_config(), preferences::load_credentials(), make_read_RWops(), wesnothd::ban_manager::read(), game_config::config_cache::read_file(), read_file(), and read_ignore_patterns().
bool filesystem::looks_like_pbl | ( | const std::string & | file | ) |
Definition at line 189 of file filesystem_common.cpp.
References utf8::lowercase(), and utils::wildcard_string_match().
Referenced by archive_dir(), BOOST_AUTO_TEST_CASE(), and get_files_in_dir().
bool filesystem::make_directory | ( | const std::string & | dirname | ) |
Definition at line 1007 of file filesystem.cpp.
References ERR_FS, and game_config::path.
Referenced by lg::check_log_dir_writable(), and gui2::dialogs::file_dialog::on_dir_create_cmd().
rwops_ptr filesystem::make_read_RWops | ( | const std::string & | path | ) |
Definition at line 49 of file filesystem_sdl.cpp.
References ERR_FS, ifs_close(), ifs_read(), ifs_seek(), ifs_size(), ifs_write(), istream_file(), game_config::path, and read_type.
Referenced by image::add_localized_overlay(), sound::load_chunk(), image::load_image_file(), and sound::play_new_music().
rwops_ptr filesystem::make_write_RWops | ( | const std::string & | path | ) |
Definition at line 72 of file filesystem_sdl.cpp.
References ERR_FS, ofs_close(), ofs_read(), ofs_seek(), ofs_size(), ofs_write(), ostream_file(), game_config::path, and write_type.
Referenced by image::save_image().
std::string filesystem::nearest_extant_parent | ( | const std::string & | file | ) |
Finds the nearest parent in existence for a file or directory.
Definition at line 1247 of file filesystem.cpp.
References is_root(), p, and game_config::path.
Referenced by BOOST_AUTO_TEST_CASE(), and gui2::dialogs::file_dialog::set_path().
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.
path | Original path. |
normalize_separators | Whether to substitute path separators with the platform's preferred format. |
resolve_dot_entries | Whether to resolve . and .. directory entries. This requires path to refer to a valid existing object. |
Definition at line 1322 of file filesystem.cpp.
References p, and game_config::path.
Referenced by autodetect_game_data_dir(), game_launcher::goto_editor(), campaignd::server::load_config(), gui2::dialogs::file_dialog::path(), gui2::dialogs::game_version::pre_show(), process_command_args(), gui2::dialogs::file_dialog::register_new_selection(), run_campaignd(), sanitize_path(), gui2::dialogs::file_dialog::set_path(), set_user_data_dir(), gui2::dialogs::file_dialog::sync_bookmarks_bar(), and campaignd::server::write_config().
|
static |
Definition at line 212 of file filesystem_sdl.cpp.
Referenced by make_write_RWops().
|
static |
Definition at line 183 of file filesystem_sdl.cpp.
Referenced by make_write_RWops().
|
static |
Definition at line 152 of file filesystem_sdl.cpp.
References translate_seekdir().
Referenced by make_write_RWops().
|
static |
Definition at line 107 of file filesystem_sdl.cpp.
Referenced by make_write_RWops().
|
static |
Definition at line 192 of file filesystem_sdl.cpp.
References utf8::size().
Referenced by make_write_RWops().
filesystem::scoped_ostream filesystem::ostream_file | ( | const std::string & | fname, |
std::ios_base::openmode | mode, | ||
bool | create_directory | ||
) |
Definition at line 1114 of file filesystem.cpp.
References e, LOG_FS, and game_config::path.
Referenced by handle_preprocess_command(), make_write_RWops(), savegame::savegame::open_save_game(), preprocess_resource(), persist_file_context::save_context(), preferences::save_credentials(), wesnothd::game::save_replay(), set_addon_pbl_info(), lg::set_log_to_file(), display::update_fps_label(), wesnothd::ban_manager::write(), write_addon_install_info(), write_file(), game_config::config_cache::write_file(), preferences::write_preferences(), and savegame::save_index_class::write_save_index().
char filesystem::path_separator | ( | ) |
Returns the standard path separator for the current platform.
Definition at line 1274 of file filesystem.cpp.
|
static |
Definition at line 293 of file filesystem.cpp.
Referenced by get_files_in_dir().
std::string filesystem::read_file | ( | const std::string & | fname | ) |
Basic disk I/O - read file.
Definition at line 1068 of file filesystem.cpp.
References istream_file().
Referenced by campaignd::add_license(), archive_file(), BOOST_AUTO_TEST_CASE(), copy_file(), wesnothd::server::load_config(), font::manager::manager(), editor::map_context::map_context(), read_map(), editor::map_context::save_map(), and game_launcher::start_wesnothd().
std::string filesystem::read_map | ( | const std::string & | name | ) |
Definition at line 223 of file filesystem_common.cpp.
References get_binary_file_location(), get_user_data_dir(), get_wml_location(), and read_file().
Referenced by saved_game::expand_map_file(), mp::game_info::game_info(), and ng::create_engine::init_all_levels().
std::string filesystem::root_name | ( | const std::string & | path | ) |
Returns the name of the root device if included in the given path.
This only properly makes sense on Windows with paths containing a drive letter or UNC at the start – otherwise, it will return the empty string. To ensure that a suitable root name can be found you might want to use normalize_path() first with resolve_dot_entries set to true.
Definition at line 1312 of file filesystem.cpp.
References game_config::path.
Referenced by gui2::dialogs::file_dialog::register_new_selection().
std::string filesystem::sanitize_path | ( | const std::string & | path | ) |
Sanitizes a path to remove references to the user's name.
Definition at line 1665 of file filesystem.cpp.
References normalize_path(), and game_config::path.
Referenced by game_config::full_build_report(), and get_addon_pbl_info().
void filesystem::set_cache_dir | ( | const std::string & | newcachedir | ) |
Definition at line 814 of file filesystem.cpp.
References set_cache_path().
Referenced by process_command_args().
|
static |
Definition at line 806 of file filesystem.cpp.
References cache_dir, create_directory_if_missing_recursive(), and ERR_FS.
Referenced by set_cache_dir().
bool filesystem::set_cwd | ( | const std::string & | dir | ) |
Definition at line 962 of file filesystem.cpp.
References ERR_FS, LOG_FS, and game_config::path.
Referenced by run_campaignd().
void filesystem::set_user_config_dir | ( | const std::string & | newconfigdir | ) |
Definition at line 801 of file filesystem.cpp.
References set_user_config_path().
Referenced by process_command_args().
|
static |
Definition at line 793 of file filesystem.cpp.
References create_directory_if_missing_recursive(), ERR_FS, and user_config_dir.
Referenced by get_user_config_dir(), and set_user_config_dir().
void filesystem::set_user_data_dir | ( | std::string | newprefdir | ) |
Definition at line 662 of file filesystem.cpp.
References _(), create_directory_if_missing(), deprecated_message(), ERR_FS, FOR_REMOVAL, get_cwd(), get_version_path_suffix(), normalize_path(), game_config::path, setup_user_data_dir(), and user_data_dir.
Referenced by get_user_data_path(), and process_command_args().
|
static |
Definition at line 620 of file filesystem.cpp.
References game_config::check_migration, create_directory_if_missing(), create_directory_if_missing_recursive(), ERR_FS, file_exists(), get_logs_dir(), and user_data_dir.
Referenced by set_user_data_dir().
|
static |
Definition at line 1594 of file filesystem.cpp.
References game_config::path.
Referenced by get_independent_binary_file_path(), and get_short_wml_path().
|
static |
Definition at line 122 of file filesystem_sdl.cpp.
Referenced by ifs_seek(), and ofs_seek().
void filesystem::write_file | ( | const std::string & | fname, |
const std::string & | data, | ||
std::ios_base::openmode | mode | ||
) |
Throws io_exception if an error occurs.
Definition at line 1133 of file filesystem.cpp.
References data, i, and ostream_file().
Referenced by lg::check_log_dir_writable(), copy_file(), network::download(), preprocess_resource(), editor::map_context::save_map(), events::menu_handler::save_map(), editor::map_context::save_scenario(), game_launcher::start_wesnothd(), and unarchive_file().
|
static |
Definition at line 567 of file filesystem.cpp.
Referenced by get_cache_dir(), and set_cache_path().
const blacklist_pattern_list filesystem::default_blacklist |
Definition at line 259 of file filesystem.cpp.
Referenced by lua_fileops::intf_read_file(), is_legal_file(), and read_ignore_patterns().
|
static |
Definition at line 30 of file filesystem_sdl.cpp.
Referenced by make_read_RWops().
|
static |
Definition at line 567 of file filesystem.cpp.
Referenced by get_user_config_dir(), and set_user_config_path().
|
static |
Definition at line 567 of file filesystem.cpp.
Referenced by get_user_data_path(), set_user_data_dir(), and setup_user_data_dir().
|
static |
Definition at line 31 of file filesystem_sdl.cpp.
Referenced by make_write_RWops().