#include <time.h>
#include <iosfwd>
#include <string>
#include <vector>
Go to the source code of this file.
Classes | |
struct | io_exception |
An exception object used when an IO error occurs. More... | |
struct | file_tree_checksum |
struct | binary_paths_manager |
class | scoped_istream |
class | scoped_ostream |
Enumerations | |
enum | FILE_NAME_MODE { ENTIRE_FILE_PATH, FILE_NAME_ONLY } |
enum | FILE_FILTER { NO_FILTER, SKIP_MEDIA_DIR } |
enum | FILE_REORDER_OPTION { DONT_REORDER, DO_REORDER } |
Functions | |
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. | |
std::string | get_dir (const std::string &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_user_data_dir () |
std::string | get_cwd () |
bool | make_directory (const std::string &dirname) |
bool | delete_directory (const std::string &dirname) |
std::string | read_file (const std::string &fname) |
Basic disk I/O - read file. | |
std::istream * | istream_file (std::string const &fname) |
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) |
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 file with name already exists. | |
time_t | file_create_time (const std::string &fname) |
Get the creation time of a file. | |
std::string | next_filename (const std::string &dirname, unsigned int max=0) |
Return the next ordered full filename within this directory. | |
bool | is_gzip_file (const std::string &filename) |
Returns true if the file ends with '.gz'. | |
bool | operator== (const file_tree_checksum &lhs, const file_tree_checksum &rhs) |
bool | operator!= (const file_tree_checksum &lhs, const file_tree_checksum &rhs) |
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. | |
bool | ends_with (const std::string &str, const std::string &suffix) |
std::string | file_name (const std::string &file) |
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. | |
void | clear_binary_paths_cache () |
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. | |
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 a type of binary, or an empty string if the file isn't present. |
Definition in file filesystem.hpp.
enum FILE_FILTER |
enum FILE_NAME_MODE |
enum FILE_REORDER_OPTION |
void clear_binary_paths_cache | ( | ) |
const file_tree_checksum& data_tree_checksum | ( | bool | reset = false |
) |
Get the time at which the data/ tree was last modified at.
bool delete_directory | ( | const std::string & | dirname | ) |
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().
std::string directory_name | ( | const std::string & | file | ) |
Returns the directory name of a file, with filename stripped.
Equivalent to a portable dirname()
Referenced by map_editor::check_data(), preprocessor_data::get_chunk(), and preprocessor_file::preprocessor_file().
bool ends_with | ( | const std::string & | str, | |
const std::string & | suffix | |||
) |
time_t file_create_time | ( | const std::string & | fname | ) |
bool file_exists | ( | const std::string & | name | ) |
Returns true if file with name already exists.
Referenced by archive_campaign(), available_campaigns(), map_editor::check_data(), map_editor::edit_save_as(), gui::file_menu::file_menu(), get_campaign_info(), preprocessor_data::get_chunk(), get_next_filename(), installed_campaigns(), open_font(), read_ignore_patterns(), save_game_exists(), events::menu_handler::save_map(), and font::set_font_list().
std::string file_name | ( | const std::string & | file | ) |
Returns the base filename of a file, with directory name stripped.
Equivalent to a portable basename() function.
Referenced by cutter::find_configuration(), and upload_log::~upload_log().
int file_size | ( | const std::string & | fname | ) |
Returns the size of a file, or -1 if the file doesn't exist.
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 a type of binary, or an empty string if the file isn't present.
Referenced by image::exists(), init_textdomains(), sound::load_chunk(), image::locator::load_image_file(), loadscreen::loadscreen(), and sound::play_new_music().
const std::vector<std::string>& get_binary_paths | ( | const std::string & | type | ) |
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 | ) |
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().
bool is_directory | ( | const std::string & | fname | ) |
Returns true if the given file is a directory.
Referenced by map_editor::check_data(), preprocessor_data::get_chunk(), get_files_in_dir(), gui::file_menu::is_directory(), main(), and preprocessor_file::preprocessor_file().
bool is_gzip_file | ( | const std::string & | filename | ) |
Returns true if the file ends with '.gz'.
Referenced by dialogs::get_save_name(), play_game(), and read_save_file().
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 & | dirname | ) |
Definition at line 326 of file filesystem.cpp.
References AccessMode, and mkdir.
Referenced by setup_dirs(), and unarchive_dir().
std::string next_filename | ( | const std::string & | dirname, | |
unsigned int | max = 0 | |||
) |
Return the next ordered full filename within this directory.
Referenced by get_next_filename(), upload_log::upload_log(), and upload_log::~upload_log().
bool operator!= | ( | const file_tree_checksum & | lhs, | |
const file_tree_checksum & | rhs | |||
) |
bool operator== | ( | const file_tree_checksum & | lhs, | |
const file_tree_checksum & | rhs | |||
) |
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 | ( | const std::string & | 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().
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().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |