#include "global.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <cstdlib>
#include <cerrno>
#include <string>
#include <cstring>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <set>
#include "wesconfig.h"
#include "config.hpp"
#include "filesystem.hpp"
#include "game_config.hpp"
#include "log.hpp"
#include "scoped_resource.hpp"
#include "util.hpp"
#include "loadscreen.hpp"
Go to the source code of this file.
Defines | |
#define | DBG_FS LOG_STREAM(debug, filesystem) |
#define | LOG_FS LOG_STREAM(info, filesystem) |
#define | ERR_FS LOG_STREAM(err, filesystem) |
#define | MAINCFG "_main.cfg" |
#define | FINALCFG "_final.cfg" |
#define | PREFERENCES_DIR ".wesnoth" |
Functions | |
bool | ends_with (const std::string &str, const std::string &suffix) |
void | get_files_in_dir (const std::string directory, std::vector< std::string > *files, std::vector< std::string > *dirs, FILE_NAME_MODE mode, FILE_FILTER filter, FILE_REORDER_OPTION reorder) |
Populates 'files' with all the files and 'dirs' with all the directories in dir. | |
std::string | get_prefs_file () |
std::string | get_save_index_file () |
std::string | get_saves_dir () |
std::string | get_cache_dir () |
std::string | get_intl_dir () |
std::string | get_screenshot_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. | |
std::string | get_upload_dir () |
std::string | get_dir (const std::string &dir_path) |
bool | make_directory (const std::string &path) |
bool | delete_directory (const std::string &path) |
std::string | get_cwd () |
std::string | get_user_data_dir () |
static std::string | read_stream (std::istream &s) |
std::istream * | istream_file (std::string const &fname) |
std::string | read_file (std::string const &fname) |
Basic disk I/O - read file. | |
std::ostream * | ostream_file (std::string const &fname) |
void | write_file (const std::string &fname, const std::string &data) |
Throws io_exception if an error occurs. | |
std::string | read_map (const std::string &name) |
static bool | is_directory_internal (const std::string &fname) |
Variables | |
const mode_t | AccessMode = 00770 |
Definition in file filesystem.cpp.
#define DBG_FS LOG_STREAM(debug, filesystem) |
Definition at line 64 of file filesystem.cpp.
#define ERR_FS LOG_STREAM(err, filesystem) |
#define FINALCFG "_final.cfg" |
#define LOG_FS LOG_STREAM(info, filesystem) |
Definition at line 65 of file filesystem.cpp.
Referenced by delete_directory(), get_files_in_dir(), istream_file(), and ostream_file().
#define MAINCFG "_main.cfg" |
#define PREFERENCES_DIR ".wesnoth" |
Referenced by get_user_data_dir().
bool delete_directory | ( | const std::string & | path | ) |
Definition at line 333 of file filesystem.cpp.
References delete_directory(), ENTIRE_FILE_PATH, get_files_in_dir(), and LOG_FS.
Referenced by delete_directory(), and upload_logs().
bool ends_with | ( | const std::string & | str, | |
const std::string & | suffix | |||
) |
std::string get_cache_dir | ( | ) |
std::string get_cwd | ( | ) |
Definition at line 366 of file filesystem.cpp.
References buf.
Referenced by get_intl_dir(), and main().
std::string get_dir | ( | const std::string & | dir_path | ) |
Definition at line 306 of file filesystem.cpp.
References AccessMode, closedir(), ERR_FS, mkdir, and opendir().
Referenced by map_editor::edit_load_map(), map_editor::edit_save_as(), get_cache_dir(), get_saves_dir(), get_screenshot_dir(), get_upload_dir(), and events::menu_handler::save_map().
void get_files_in_dir | ( | const std::string | dir, | |
std::vector< std::string > * | files, | |||
std::vector< std::string > * | dirs = NULL , |
|||
FILE_NAME_MODE | mode = FILE_NAME_ONLY , |
|||
FILE_FILTER | = NO_FILTER , |
|||
FILE_REORDER_OPTION | reorder = DONT_REORDER | |||
) |
Populates 'files' with all the files and 'dirs' with all the directories in dir.
If files or dirs are NULL they will not be used.
Mode determines whether the entire path or just the filename is retrieved.
Definition at line 89 of file filesystem.cpp.
References closedir(), dirent::d_name, DO_REORDER, ends_with(), ENTIRE_FILE_PATH, FINALCFG, get_files_in_dir(), is_directory(), LOG_FS, MAINCFG, opendir(), game_config::path, readdir(), S_ISDIR, S_ISREG, and SKIP_MEDIA_DIR.
Referenced by archive_dir(), available_campaigns(), mp::create::create(), delete_directory(), get_files_in_dir(), get_saves_list(), installed_campaigns(), preprocessor_file::preprocessor_file(), gui::file_menu::update_file_lists(), and upload_logs().
std::string get_intl_dir | ( | ) |
Definition at line 255 of file filesystem.cpp.
References get_cwd(), LOCALEDIR, and game_config::path.
Referenced by init_textdomains(), main(), and play_game().
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.
Definition at line 280 of file filesystem.cpp.
References file_exists(), and next_filename().
Referenced by hotkey::execute_command().
std::string get_prefs_file | ( | ) |
Definition at line 233 of file filesystem.cpp.
References get_user_data_dir().
Referenced by preferences::base_manager::base_manager(), and preferences::write_preferences().
std::string get_save_index_file | ( | ) |
Definition at line 238 of file filesystem.cpp.
References get_user_data_dir().
Referenced by save_index(), and write_save_index().
std::string get_saves_dir | ( | ) |
Definition at line 243 of file filesystem.cpp.
References get_dir(), and get_user_data_dir().
Referenced by delete_game(), finish_save_game(), get_saves_list(), open_save_game(), read_save_file(), and save_game_exists().
std::string get_screenshot_dir | ( | ) |
Definition at line 274 of file filesystem.cpp.
References get_dir(), and get_user_data_dir().
Referenced by hotkey::execute_command().
std::string get_upload_dir | ( | ) |
Definition at line 300 of file filesystem.cpp.
References get_dir(), and get_user_data_dir().
Referenced by upload_log_dialog::show_beg_dialog(), upload_log::upload_log(), upload_logs(), and upload_log::~upload_log().
std::string get_user_data_dir | ( | ) |
Definition at line 383 of file filesystem.cpp.
References AccessMode, buf, closedir(), ERR_FS, mkdir, opendir(), and PREFERENCES_DIR.
Referenced by campaign_dir(), map_editor::check_data(), mp::create::create(), map_editor::edit_load_map(), map_editor::edit_save_as(), get_cache_dir(), preprocessor_data::get_chunk(), get_prefs_file(), get_save_index_file(), get_saves_dir(), get_screenshot_dir(), get_upload_dir(), read_map(), events::menu_handler::save_map(), and setup_dirs().
static bool is_directory_internal | ( | const std::string & | fname | ) | [static] |
std::istream* istream_file | ( | std::string const & | fname | ) |
Definition at line 486 of file filesystem.cpp.
References LOG_FS, and game_config::path.
Referenced by preferences::base_manager::base_manager(), check_python_scripts(), get_campaign_info(), map_editor::map_editor(), play_game(), preprocessor_file::preprocessor_file(), read_file(), read_ignore_patterns(), read_save_file(), and save_index().
bool make_directory | ( | const std::string & | path | ) |
Definition at line 326 of file filesystem.cpp.
References AccessMode, and mkdir.
Referenced by setup_dirs(), and unarchive_dir().
std::ostream* ostream_file | ( | std::string const & | fname | ) |
Definition at line 513 of file filesystem.cpp.
References LOG_FS.
Referenced by open_save_game(), play_game(), set_campaign_info(), preferences::write_preferences(), write_save_index(), map_editor::~map_editor(), and upload_log::~upload_log().
std::string read_file | ( | std::string const & | fname | ) |
Basic disk I/O - read file.
Definition at line 507 of file filesystem.cpp.
References istream_file(), and read_stream().
Referenced by add_license(), archive_file(), map_editor::check_data(), map_editor::edit_load_map(), map_editor::edit_revert(), main(), read_map(), map_editor::save_map(), and upload_logs().
std::string read_map | ( | const std::string & | name | ) |
Definition at line 542 of file filesystem.cpp.
References get_user_data_dir(), and read_file().
Referenced by play_game(), mp::create::process_event(), and mp::gamebrowser::set_game_items().
static std::string read_stream | ( | std::istream & | s | ) | [static] |
void write_file | ( | const std::string & | fname, | |
const std::string & | data | |||
) |
Throws io_exception if an error occurs.
Definition at line 520 of file filesystem.cpp.
References buf, file, and util::scoped_resource< T, ReleasePolicy >::get().
Referenced by events::menu_handler::save_map(), map_editor::save_map(), and unarchive_file().
const mode_t AccessMode = 00770 [static] |
Definition at line 69 of file filesystem.cpp.
Referenced by get_dir(), get_user_data_dir(), and make_directory().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |