Namespaces | |
| namespace | implementation |
Classes | |
| class | atomic_commit |
| Wrapper class that guarantees that file commit atomicity. More... | |
| struct | binary_paths_manager |
| The paths manager is responsible for recording the various paths that binary files may be located at. More... | |
| class | blacklist_pattern_list |
| struct | file_tree_checksum |
| struct | io_exception |
| An exception object used when an IO error occurs. More... | |
| struct | other_version_dir |
Typedefs | |
| using | scoped_istream = std::unique_ptr< std::istream > |
| using | scoped_ostream = std::unique_ptr< std::ostream > |
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 | |
| 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. | |
| std::string | get_dir (const std::string &dir) |
| std::string | autodetect_game_data_dir (std::string exe_dir) |
| Try to autodetect the location of the game data dir. | |
| std::string | get_synced_prefs_file () |
| location of preferences file containing preferences that are synced between computers note that wesnoth does not provide the syncing functionality itself | |
| std::string | get_unsynced_prefs_file () |
| location of preferences file containing preferences that aren't synced between computers | |
| std::string | get_credentials_file () |
| std::string | get_default_prefs_file () |
| std::string | get_save_index_file () |
| std::string | get_lua_history_file () |
| utils::optional< std::string > | get_game_manual_file (const std::string &locale_code, const std::string &short_locale_code) |
| location of the game manual file correponding to the given locale (default: en) | |
| std::string | get_sync_dir () |
| parent directory for everything that should be synced between systems. | |
| std::string | get_saves_dir () |
| std::string | get_wml_persist_dir () |
| std::string | get_intl_dir () |
| std::string | get_screenshot_dir () |
| std::string | get_addons_data_dir () |
| std::string | get_addons_dir () |
| std::string | get_current_editor_dir (const std::string &addon_id) |
| const std::string | get_version_path_suffix (const version_info &version) |
| const std::string & | get_version_path_suffix () |
| 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. | |
| bool | is_userdata_initialized () |
| void | set_user_data_dir (std::string path) |
| void | set_cache_dir (const std::string &path) |
| std::string | get_user_data_dir () |
| std::string | get_logs_dir () |
| std::string | get_cache_dir () |
| std::string | get_legacy_editor_dir () |
| std::string | get_core_images_dir () |
| bool | rename_dir (const std::string &old_dir, const std::string &new_dir) |
| std::vector< other_version_dir > | find_other_version_saves_dirs () |
| Searches for directories containing saves created by other versions of Wesnoth. | |
| std::string | get_cwd () |
| bool | set_cwd (const std::string &dir) |
| std::string | get_exe_path () |
| std::string | get_exe_dir () |
| std::string | get_wesnothd_name () |
| bool | make_directory (const std::string &dirname) |
| bool | delete_directory (const std::string &dirname, const bool keep_pbl=false) |
| bool | delete_file (const std::string &filename) |
| bool | looks_like_pbl (const std::string &file) |
| std::string | read_file (const std::string &fname) |
| Basic disk I/O - read file. | |
| std::vector< uint8_t > | read_file_binary (const std::string &fname) |
| std::string | read_file_as_data_uri (const std::string &fname) |
| filesystem::scoped_istream | istream_file (const std::string &fname, bool treat_failure_as_error=true) |
| filesystem::scoped_ostream | ostream_file (const std::string &fname, std::ios_base::openmode mode=std::ios_base::binary, bool create_directory=true) |
| 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. | |
| void | copy_file (const std::string &src, const std::string &dest) |
| Read a file and then writes it back out. | |
| std::string | get_map_file (const std::string &name) |
| std::string | get_scenario_file (const std::string &name) |
| std::string | read_map (const std::string &name) |
| std::string | read_scenario (const std::string &name) |
| bool | create_directory_if_missing (const std::string &dirname) |
| Creates a directory if it does not exist already. | |
| bool | create_directory_if_missing_recursive (const std::string &dirname) |
| Creates a recursive directory tree if it does not exist already. | |
| bool | is_directory (const std::string &fname) |
| Returns true if the given file is a directory. | |
| bool | file_exists (const std::string &name) |
| Returns true if a file or directory with such name already exists. | |
| std::chrono::system_clock::time_point | file_modified_time (const std::string &fname) |
| Get the modification time of a file. | |
| bool | is_map (const std::string &filename) |
| Returns true if the file ends with the mapfile extension. | |
| bool | is_cfg (const std::string &filename) |
| Returns true if the file ends with the wmlfile extension. | |
| bool | is_mask (const std::string &filename) |
| Returns true if the file ends with the maskfile extension. | |
| bool | is_gzip_file (const std::string &filename) |
| Returns true if the file ends with '.gz'. | |
| bool | is_bzip2_file (const std::string &filename) |
| Returns true if the file ends with '.bz2'. | |
| 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. | |
| 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. | |
| int | dir_size (const std::string &path) |
| Returns the sum of the sizes of the files contained in a directory. | |
| std::string | base_name (const std::string &file, const bool remove_extension=false) |
| Returns the base filename of a file, with directory name stripped. | |
| std::string | directory_name (const std::string &file) |
| Returns the directory name of a file, with filename stripped. | |
| std::string | nearest_extant_parent (const std::string &file) |
| Finds the nearest parent in existence for a file or directory. | |
| std::string | normalize_path (const std::string &path, bool normalize_separators=false, bool resolve_dot_entries=false) |
| Returns the absolute path of a file. | |
| utils::optional< std::string > | to_asset_path (const std::string &abs_path, const std::string &addon_id, const std::string &asset_type) |
| Helper function to convert absolute path to wesnoth relative path. | |
| std::string | sanitize_path (const std::string &path) |
| Sanitizes a path to remove references to the user's name. | |
| bool | is_root (const std::string &path) |
| Returns whether the path is the root of the file hierarchy. | |
| std::string | root_name (const std::string &path) |
| Returns the name of the root device if included in the given path. | |
| bool | is_relative (const std::string &path) |
| Returns whether the path seems to be relative. | |
| bool | is_path_sep (char c) |
| Returns whether c is a path separator. | |
| char | path_separator () |
| Returns the standard path separator for the current platform. | |
| void | clear_binary_paths_cache () |
| NOT_DANGLING 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. | |
| utils::optional< 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, if it exists. | |
| utils::optional< 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, if it exists. | |
| utils::optional< std::string > | get_wml_location (const std::string &path, const utils::optional< std::string > ¤t_dir=utils::nullopt) |
| Returns a translated path to the actual file or directory, if it exists. | |
| std::string | get_short_wml_path (const std::string &filename) |
| Returns a short path to filename, skipping the (user) data directory. | |
| utils::optional< 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. | |
| 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. | |
| utils::optional< std::string > | get_localized_path (const std::string &file, const std::string &suff="") |
| Returns the localized version of the given filename, if it exists. | |
| utils::optional< std::string > | get_localized_path (const utils::optional< std::string > &base_path) |
| utils::optional< std::string > | get_addon_id_from_path (const std::string &location) |
| Returns the add-on ID from a path. | |
| static void | get_file_tree_checksum_internal (const std::string &path, file_tree_checksum &res) |
Variables | |
| const std::string | map_extension |
| const std::string | mask_extension |
| const std::string | wml_extension |
| const blacklist_pattern_list | default_blacklist |
| using filesystem::scoped_istream = typedef std::unique_ptr<std::istream> |
Definition at line 52 of file filesystem.hpp.
| using filesystem::scoped_ostream = typedef std::unique_ptr<std::ostream> |
Definition at line 53 of file filesystem.hpp.
|
strong |
| Enumerator | |
|---|---|
| NO_FILTER | |
| SKIP_MEDIA_DIR | |
| SKIP_PBL_FILES | |
Definition at line 64 of file filesystem.hpp.
|
strong |
| Enumerator | |
|---|---|
| ENTIRE_FILE_PATH | |
| FILE_NAME_ONLY | |
Definition at line 63 of file filesystem.hpp.
|
strong |
| Enumerator | |
|---|---|
| DONT_REORDER | |
| DO_REORDER | |
Definition at line 65 of file filesystem.hpp.
| std::string filesystem::autodetect_game_data_dir | ( | std::string | exe_dir | ) |
Try to autodetect the location of the game data dir.
Note that the root of the source tree currently doubles as the data dir.
Definition at line 123 of file filesystem_common.cpp.
References autodetect_game_data_dir(), file_exists(), get_cwd(), and normalize_path().
Referenced by autodetect_game_data_dir(), and process_command_args().
| 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.
Referenced by editor::map_context::convert_scenario(), game_config::config_cache::delete_cache_files(), editor::context_manager::expand_load_mru_menu(), editor::context_manager::expand_open_maps_menu(), campaignd::find_translations(), filesystem::implementation::get_file_by_type(), editor::map_context::load_scenario(), 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(), and editor::context_manager::set_window_title().
| void filesystem::clear_binary_paths_cache | ( | ) |
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. |
Referenced by gui2::dialogs::migrate_version_selection::migrate_credentials(), prefs::migrate_preferences(), gui2::dialogs::custom_tod::select_file(), and gui2::dialogs::editor_edit_unit::select_file().
| 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. |
Referenced by editor::initialize_addon().
| 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 |
Referenced by preprocess_resource().
| 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 327 of file filesystem_common.cpp.
References get_file_tree_checksum_internal(), get_user_data_dir(), LOG_FS, filesystem::file_tree_checksum::nfiles, 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 = false |
||
| ) |
| bool filesystem::delete_file | ( | const std::string & | filename | ) |
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 prefs::save_credentials().
| int filesystem::dir_size | ( | const std::string & | path | ) |
Returns the sum of the sizes of the files contained in a directory.
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()
Referenced by lua_fileops::get_calling_file(), preprocessor_data::get_chunk(), preprocessor_file::init(), 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 prefs::show_wesnothd_server_search().
| bool filesystem::file_exists | ( | const std::string & | name | ) |
Returns true if a file or directory with such name already exists.
Referenced by ad_hoc_addon_fetch_session(), autodetect_game_data_dir(), lg::check_log_dir_writable(), editor::map_context::convert_scenario(), network::gui_download(), handle_preprocess_command(), handle_preprocess_string(), have_addon_in_vcs_tree(), have_addon_install_info(), have_addon_pbl_info(), gui2::init(), editor::initialize_addon(), installed_addons_and_versions(), is_addon_installed(), persist_file_context::load(), game_config_manager::load_addons_cfg(), prefs::load_credentials(), game_config_manager::load_game_config(), gui::button::load_images(), editor::map_context::map_context(), gui2::dialogs::migrate_version_selection::migrate_credentials(), prefs::migrate_preferences(), gui2::dialogs::migrate_version_selection::migrate_version_selection(), desktop::os_version(), gui2::dialogs::editor_choose_addon::populate_list(), hotkey::command_executor::populate_menu_controls(), gui2::dialogs::migrate_version_selection::post_show(), gui2::dialogs::editor_edit_pbl::pre_show(), gui2::dialogs::game_version::pre_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(), prefs::save_credentials(), savegame::save_game_exists(), savegame::save_index_class::save_index_class(), editor::map_context::save_schedule(), hotkey::command_executor_default::set_button_state(), gui2::dialogs::preferences_dialog::setup_hotkey_list(), editor::start(), game_launcher::start_wesnothd(), gui2::dialogs::editor_edit_pbl::update_icon_preview(), game_config::config_cache::write_file(), and prefs::write_preferences().
| std::chrono::system_clock::time_point filesystem::file_modified_time | ( | const std::string & | fname | ) |
Get the modification time of a file.
Referenced by prefs::migrate_preferences(), 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.
Referenced by lg::check_log_dir_writable(), coro_send_file_userspace(), 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.
Referenced by gui2::dialogs::game_load::execute(), and gui2::dialogs::game_load::set_save_dir_list().
| utils::optional< std::string > filesystem::get_addon_id_from_path | ( | const std::string & | location | ) |
Returns the add-on ID from a path.
aka the directory directly following the "add-ons" folder, or an empty string if none is found.
Referenced by editor::context_manager::load_map().
| std::string filesystem::get_addons_data_dir | ( | ) |
Definition at line 199 of file filesystem_common.cpp.
References get_addons_data_dir(), get_dir(), and get_user_data_dir().
Referenced by get_addons_data_dir(), and get_addons_dir().
| std::string filesystem::get_addons_dir | ( | ) |
Definition at line 205 of file filesystem_common.cpp.
References get_addons_data_dir(), get_addons_dir(), and get_dir().
Referenced by ad_hoc_addon_fetch_session(), archive_addon(), game_config::full_build_report(), gui2::dialogs::game_version::game_version(), get_addons_dir(), get_current_editor_dir(), have_addon_in_vcs_tree(), gui2::init(), editor::initialize_addon(), 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::editor_choose_addon::populate_list(), gui2::dialogs::migrate_version_selection::post_show(), gui2::dialogs::editor_edit_pbl::pre_show(), purge_addon(), read_ignore_patterns(), achievements::reload(), remove_local_addon(), and unarchive_addon().
| utils::optional< 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, if it exists.
Referenced by init_textdomains().
| utils::optional< 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, if it exists.
Referenced by image::build_spritesheet_from(), image::exists(), filesystem::implementation::get_file_by_type(), unit_race::get_icon_path_stem(), intf_have_asset(), and image::load_image_file().
| NOT_DANGLING 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,
Referenced by image::precache_file_existence().
| std::string filesystem::get_cache_dir | ( | ) |
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_core_images_dir | ( | ) |
Definition at line 232 of file filesystem_common.cpp.
References get_core_images_dir(), and game_config::path.
Referenced by get_core_images_dir(), gui2::dialogs::editor_edit_pbl::select_icon_file(), and gui2::dialogs::editor_edit_pbl::update_icon_preview().
| std::string filesystem::get_credentials_file | ( | ) |
Definition at line 164 of file filesystem_common.cpp.
References get_credentials_file(), and get_user_data_dir().
Referenced by get_credentials_file(), prefs::load_credentials(), gui2::dialogs::migrate_version_selection::migrate_credentials(), gui2::dialogs::migrate_version_selection::post_show(), and prefs::save_credentials().
| std::string filesystem::get_current_editor_dir | ( | const std::string & | addon_id | ) |
Definition at line 223 of file filesystem_common.cpp.
References get_addons_dir(), get_current_editor_dir(), and game_config::path.
Referenced by editor::context_manager::apply_mask_dialog(), editor::context_manager::change_addon_id(), editor::map_context::convert_scenario(), editor::context_manager::create_mask_to_dialog(), editor::editor_controller::do_execute_command(), editor::context_manager::edit_pbl(), get_current_editor_dir(), editor::context_manager::load_map_dialog(), editor::map_context::load_scenario(), editor::context_manager::save_map_as_dialog(), editor::context_manager::save_scenario_as_dialog(), editor::map_context::save_schedule(), gui2::dialogs::custom_tod::select_file(), gui2::dialogs::editor_edit_unit::select_file(), editor::map_context::to_config(), and gui2::dialogs::editor_edit_unit::write().
| std::string filesystem::get_cwd | ( | ) |
Referenced by autodetect_game_data_dir(), main(), run_campaignd(), and wesnoth_global_fixture::wesnoth_global_fixture().
| std::string filesystem::get_default_prefs_file | ( | ) |
Definition at line 169 of file filesystem_common.cpp.
References game_config::default_preferences_path, get_default_prefs_file(), and game_config::path.
Referenced by get_default_prefs_file(), and prefs::load_preferences().
| std::string filesystem::get_dir | ( | const std::string & | dir | ) |
| std::string filesystem::get_exe_dir | ( | ) |
Referenced by desktop::game_paths(), process_command_args(), and prefs::show_wesnothd_server_search().
| std::string filesystem::get_exe_path | ( | ) |
|
static |
Definition at line 316 of file filesystem_common.cpp.
References DONT_REORDER, ENTIRE_FILE_PATH, get_file_tree_checksum_internal(), get_files_in_dir(), and SKIP_MEDIA_DIR.
Referenced by data_tree_checksum(), and get_file_tree_checksum_internal().
| 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. |
Referenced by archive_dir(), game_config::config_cache::clean_cache(), savegame::save_index_class::clean_up_index(), ng::create_engine::create_engine(), get_file_tree_checksum_internal(), savegame::save_index_class::get_saves_list(), gui2::init(), lua_fileops::intf_read_file(), game_config_manager::load_addons_cfg(), campaignd::server::load_config(), game_config_manager::load_game_config(), gui2::dialogs::editor_choose_addon::populate_list(), gui2::dialogs::migrate_version_selection::post_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::editor_edit_pbl::pre_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().
| utils::optional< std::string > filesystem::get_game_manual_file | ( | const std::string & | locale_code, |
| const std::string & | short_locale_code | ||
| ) |
location of the game manual file correponding to the given locale (default: en)
Referenced by gui2::dialogs::game_version::show_manual().
| utils::optional< 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
Referenced by 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 237 of file filesystem_common.cpp.
References get_intl_dir(), LOCALEDIR, and game_config::path.
Referenced by test_utils::game_config_manager::game_config_manager(), get_intl_dir(), init_locale(), and init_textdomains().
| std::string filesystem::get_legacy_editor_dir | ( | ) |
Definition at line 217 of file filesystem_common.cpp.
References get_dir(), get_legacy_editor_dir(), and get_sync_dir().
Referenced by ng::create_engine::create_engine(), desktop::game_paths(), filesystem::implementation::get_file_by_type(), get_legacy_editor_dir(), ng::create_engine::init_all_levels(), editor::context_manager::load_map_dialog(), events::menu_handler::save_map(), and editor::context_manager::save_map_as_dialog().
| utils::optional< 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.
Referenced by image::load_image_file().
| utils::optional< std::string > filesystem::get_localized_path | ( | const utils::optional< std::string > & | base_path | ) |
| std::string filesystem::get_logs_dir | ( | ) |
| std::string filesystem::get_lua_history_file | ( | ) |
Definition at line 183 of file filesystem_common.cpp.
References get_lua_history_file(), and get_sync_dir().
Referenced by get_lua_history_file().
| std::string filesystem::get_map_file | ( | const std::string & | name | ) |
Definition at line 296 of file filesystem_common.cpp.
References filesystem::implementation::get_file_by_type().
Referenced by editor::map_context::map_context(), and read_map().
| 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.
Referenced by editor::map_context::convert_scenario().
| 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.
| std::string filesystem::get_save_index_file | ( | ) |
Definition at line 178 of file filesystem_common.cpp.
References get_save_index_file(), and get_user_data_dir().
Referenced by get_save_index_file(), savegame::save_index_class::save_index_class(), and savegame::save_index_class::write_save_index().
| std::string filesystem::get_saves_dir | ( | ) |
Definition at line 193 of file filesystem_common.cpp.
References get_dir(), get_saves_dir(), and get_sync_dir().
Referenced by game_config::full_build_report(), gui2::dialogs::game_version::game_version(), get_saves_dir(), playsingle_controller::hotkey_handler::load_autosave(), and gui2::dialogs::mp_match_history::update_display().
| std::string filesystem::get_scenario_file | ( | const std::string & | name | ) |
Definition at line 301 of file filesystem_common.cpp.
References filesystem::implementation::get_file_by_type().
Referenced by read_scenario().
| std::string filesystem::get_screenshot_dir | ( | ) |
Definition at line 246 of file filesystem_common.cpp.
References get_dir(), get_screenshot_dir(), and get_user_data_dir().
Referenced by gui2::dialogs::game_version::game_version(), and get_screenshot_dir().
| std::string filesystem::get_short_wml_path | ( | const std::string & | filename | ) |
Returns a short path to filename, skipping the (user) data directory.
Referenced by preprocessor_file::init(), game_config_manager::load_addons_cfg(), and editor::map_context::map_context().
| std::string filesystem::get_sync_dir | ( | ) |
parent directory for everything that should be synced between systems.
implemented due to limitations of Steam's AutoCloud (non-SDK) syncing, but will also simplify things if it's ever added for any other platforms.
Definition at line 188 of file filesystem_common.cpp.
References get_sync_dir(), and get_user_data_dir().
Referenced by get_legacy_editor_dir(), get_lua_history_file(), get_saves_dir(), get_sync_dir(), get_synced_prefs_file(), and get_wml_persist_dir().
| std::string filesystem::get_synced_prefs_file | ( | ) |
location of preferences file containing preferences that are synced between computers note that wesnoth does not provide the syncing functionality itself
Definition at line 154 of file filesystem_common.cpp.
References get_sync_dir(), and get_synced_prefs_file().
Referenced by get_synced_prefs_file(), prefs::load_preferences(), prefs::migrate_preferences(), gui2::dialogs::migrate_version_selection::post_show(), and prefs::write_preferences().
| std::string filesystem::get_unsynced_prefs_file | ( | ) |
location of preferences file containing preferences that aren't synced between computers
Definition at line 159 of file filesystem_common.cpp.
References get_unsynced_prefs_file(), and get_user_data_dir().
Referenced by get_unsynced_prefs_file(), prefs::load_preferences(), gui2::dialogs::migrate_version_selection::post_show(), and prefs::write_preferences().
| std::string filesystem::get_user_data_dir | ( | ) |
Referenced by data_tree_checksum(), game_config::full_build_report(), game_launcher::game_launcher(), desktop::game_paths(), gui2::dialogs::game_version::game_version(), get_addons_data_dir(), get_credentials_file(), get_save_index_file(), get_screenshot_dir(), get_sync_dir(), get_unsynced_prefs_file(), gui2::dialogs::migrate_version_selection::old_config_dir(), process_command_args(), and game_launcher::start_wesnothd().
| const std::string & filesystem::get_version_path_suffix | ( | ) |
| const std::string filesystem::get_version_path_suffix | ( | const version_info & | version | ) |
| std::string filesystem::get_wesnothd_name | ( | ) |
Referenced by prefs::show_wesnothd_server_search(), and game_launcher::start_wesnothd().
| utils::optional< std::string > filesystem::get_wml_location | ( | const std::string & | path, |
| const utils::optional< std::string > & | current_dir = utils::nullopt |
||
| ) |
Returns a translated path to the actual file or directory, if it exists.
current_dir is needed to resolve a path starting with ".".
Referenced by wfl::gamestate::DEFINE_WFL_FUNCTION(), get_addon_pbl_info(), preprocessor_data::get_chunk(), filesystem::implementation::get_file_by_type(), 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(), lua_fileops::resolve_filename(), game_launcher::start_wesnothd(), and gui2::dialogs::editor_edit_pbl::validate().
| std::string filesystem::get_wml_persist_dir | ( | ) |
Definition at line 211 of file filesystem_common.cpp.
References get_dir(), get_sync_dir(), and get_wml_persist_dir().
Referenced by get_persist_cfg_name(), and get_wml_persist_dir().
| bool filesystem::is_bzip2_file | ( | const std::string & | filename | ) |
Returns true if the file ends with '.bz2'.
Referenced by is_compressed_file(), and savegame::read_save_file().
| bool filesystem::is_cfg | ( | const std::string & | filename | ) |
Returns true if the file ends with the wmlfile extension.
Referenced by archive_file(), editor::editor_controller::do_execute_command(), ng::create_engine::init_all_levels(), game_config_manager::load_addons_cfg(), editor::context_manager::load_map(), editor::map_context::map_context(), and preprocess_resource().
|
inline |
Definition at line 285 of file filesystem.hpp.
References filename, is_bzip2_file(), and is_gzip_file().
Referenced by savegame::savegame::check_filename().
| bool filesystem::is_directory | ( | const std::string & | fname | ) |
Returns true if the given file is a directory.
Referenced by lua_fileops::intf_have_file(), lua_fileops::intf_read_file(), 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_map(), gui2::dialogs::file_dialog::set_path(), prefs::show_wesnothd_server_search(), and editor::start().
| bool filesystem::is_gzip_file | ( | const std::string & | filename | ) |
Returns true if the file ends with '.gz'.
Referenced by is_compressed_file(), and savegame::read_save_file().
| 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_map | ( | const std::string & | filename | ) |
Returns true if the file ends with the mapfile extension.
Referenced by editor::editor_controller::do_execute_command(), and editor::map_context::map_context().
| bool filesystem::is_mask | ( | const std::string & | filename | ) |
Returns true if the file ends with the maskfile extension.
Referenced by editor::map_context::map_context().
| bool filesystem::is_path_sep | ( | char | c | ) |
Returns whether c is a path separator.
| bool filesystem::is_relative | ( | const std::string & | path | ) |
Returns whether the path seems to be relative.
Referenced by 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.
Referenced by gui2::dialogs::file_dialog::get_filelist_selection(), gui2::dialogs::file_dialog::refresh_fileview(), and gui2::dialogs::file_dialog::register_new_selection().
| bool filesystem::is_userdata_initialized | ( | ) |
Referenced by process_command_args().
| filesystem::scoped_istream filesystem::istream_file | ( | const std::string & | fname, |
| bool | treat_failure_as_error = true |
||
| ) |
Referenced by coro_send_file_userspace(), savegame::find_save_file(), get_addon_install_info(), get_addon_pbl_info(), handle_preprocess_command(), handle_preprocess_string(), 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(), campaignd::server::load_blacklist(), campaignd::server::load_config(), prefs::load_credentials(), prefs::load_preferences(), prefs::migrate_preferences(), wesnothd::ban_manager::read(), game_config::config_cache::read_file(), read_ignore_patterns(), and savegame::save_index_class::save_index_class().
| bool filesystem::looks_like_pbl | ( | const std::string & | file | ) |
Definition at line 252 of file filesystem_common.cpp.
References looks_like_pbl(), utf8::lowercase(), and utils::wildcard_string_match().
Referenced by archive_dir(), and looks_like_pbl().
| bool filesystem::make_directory | ( | const std::string & | dirname | ) |
Referenced by lg::check_log_dir_writable(), and gui2::dialogs::file_dialog::on_dir_create_cmd().
| std::string filesystem::nearest_extant_parent | ( | const std::string & | file | ) |
Finds the nearest parent in existence for a file or directory.
Referenced by 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. |
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(), gui2::dialogs::file_dialog::set_path(), gui2::dialogs::file_dialog::sync_bookmarks_bar(), and campaignd::server::write_config().
| filesystem::scoped_ostream filesystem::ostream_file | ( | const std::string & | fname, |
| std::ios_base::openmode | mode = std::ios_base::binary, |
||
| bool | create_directory = true |
||
| ) |
Referenced by handle_preprocess_command(), editor::initialize_addon(), savegame::savegame::open_save_game(), preprocess_resource(), persist_file_context::save_context(), prefs::save_credentials(), wesnothd::game::save_replay(), set_addon_pbl_info(), wesnothd::ban_manager::write(), write_addon_install_info(), game_config::config_cache::write_file(), game_config::config_cache::write_file(), prefs::write_preferences(), and savegame::save_index_class::write_save_index().
| char filesystem::path_separator | ( | ) |
Returns the standard path separator for the current platform.
| std::string filesystem::read_file | ( | const std::string & | fname | ) |
Basic disk I/O - read file.
Referenced by campaignd::add_license(), archive_file(), BOOST_AUTO_TEST_CASE(), editor::context_manager::change_addon_id(), wfl::gamestate::DEFINE_WFL_FUNCTION(), wesnothd::server::load_config(), editor::map_context::load_scenario(), font::manager::manager(), editor::map_context::map_context(), read_map(), read_scenario(), editor::map_context::save_map(), and game_launcher::start_wesnothd().
| std::string filesystem::read_file_as_data_uri | ( | const std::string & | fname | ) |
Referenced by gui2::dialogs::editor_edit_pbl::select_icon_file().
| std::vector< uint8_t > filesystem::read_file_binary | ( | const std::string & | fname | ) |
| std::string filesystem::read_map | ( | const std::string & | name | ) |
Definition at line 306 of file filesystem_common.cpp.
References get_map_file(), and read_file().
Referenced by saved_game::expand_map_file(), mp::game_info::game_info(), ng::create_engine::init_all_levels(), and mp::lobby_info::process_gamelist().
| std::string filesystem::read_scenario | ( | const std::string & | name | ) |
Definition at line 311 of file filesystem_common.cpp.
References get_scenario_file(), and read_file().
Referenced by saved_game::expand_map_file().
| bool filesystem::rename_dir | ( | const std::string & | old_dir, |
| const std::string & | new_dir | ||
| ) |
Referenced by editor::context_manager::change_addon_id().
| 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.
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.
Referenced by game_config::full_build_report(), and get_addon_pbl_info().
| void filesystem::set_cache_dir | ( | const std::string & | path | ) |
Referenced by process_command_args().
| bool filesystem::set_cwd | ( | const std::string & | dir | ) |
Referenced by run_campaignd().
| void filesystem::set_user_data_dir | ( | std::string | path | ) |
| utils::optional< std::string > filesystem::to_asset_path | ( | const std::string & | abs_path, |
| const std::string & | addon_id, | ||
| const std::string & | asset_type | ||
| ) |
Helper function to convert absolute path to wesnoth relative path.
Referenced by gui2::dialogs::custom_tod::select_file(), and gui2::dialogs::editor_edit_unit::select_file().
| void filesystem::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.
Referenced by editor::context_manager::change_addon_id(), lg::check_log_dir_writable(), editor::map_context::convert_scenario(), network::download(), gui2::dialogs::editor_edit_pbl::post_show(), preprocess_resource(), editor::map_context::save_map(), events::menu_handler::save_map(), editor::map_context::save_scenario(), editor::map_context::save_schedule(), game_launcher::start_wesnothd(), editor::map_context::to_config(), unarchive_file(), and gui2::dialogs::editor_edit_unit::write().
|
extern |
Referenced by lua_fileops::intf_read_file(), and read_ignore_patterns().
|
extern |
|
extern |
Referenced by editor::context_manager::save_map_as_dialog().
|
extern |