Classes | |
struct | DirListNode |
Functions | |
std::vector< DirListNode > | GetDirListing (const std::string &pathstring) |
bool | CreateDir (const std::string &path) |
bool | PathExists (const std::string &path) |
bool | IsPathAbsolute (const std::string &path) |
bool | IsDir (const std::string &path) |
bool | IsExecutable (const std::string &path) |
bool | IsDirDelimiter (char c) |
bool | RecursiveDelete (const std::string &path) |
bool | DeleteSingleFileOrEmptyDirectory (const std::string &path) |
std::string | TempPath () |
Returns path to temp directory. | |
std::string | CreateTempFile () |
Returns path to securely-created temporary file (will already exist when this function returns). | |
std::string | CreateTempDir () |
Returns path to securely-created temporary directory (will already exist when this function returns). | |
bool | CopyFileContents (const std::string &source, const std::string &target) |
void | GetRecursiveDirs (std::vector< std::string > &dirs, const std::string &dir) |
std::vector< std::string > | GetRecursiveDirs (const std::string &dir) |
void | GetRecursiveSubPaths (const std::string &path, std::vector< std::string > &dst, bool list_files, const std::set< char > &ignore) |
bool | RecursiveDeleteContent (const std::string &path) |
bool | CreateAllDirs (const std::string &path) |
bool | CopyDir (const std::string &source, const std::string &target) |
bool | MoveDir (const std::string &source, const std::string &target) |
bool | PathStartsWith (const std::string &path, const std::string &prefix) |
std::string | RemoveLastPathComponent (const std::string &path, std::string *removed, int count) |
std::string | RemoveRelativePathComponents (std::string path) |
std::string | AbsolutePath (const std::string &path) |
const char * | GetFilenameFromPath (const char *path) |
bool | safeWriteToFile (const std::string &path, std::string_view content) |
bool | ReadFile (const std::string &path, std::string &out, bool log_error) |
bool | Rename (const std::string &from, const std::string &to) |
bool | OpenStream (std::filebuf &stream, const char *filename, std::ios::openmode mode, bool log_error, bool log_warn) |
Open a file buffer with error handling, commonly used with std::fstream.rdbuf() . | |
bool | IsFile (const std::string &path) |
std::string fs::AbsolutePath | ( | const std::string & | path | ) |
Referenced by ScriptApiSecurity::checkPath(), ScriptApiSecurity::checkPathWithGamedef(), findSubgame(), and ModApiMainMenu::l_get_modpaths().
bool fs::CopyDir | ( | const std::string & | source, |
const std::string & | target ) |
References CopyDir(), CopyFileContents(), CreateAllDirs(), DIR_DELIM, GetDirListing(), and PathExists().
Referenced by CopyDir(), ModApiMainMenu::l_copy_dir(), ModApiUtil::l_cpdir(), and MoveDir().
bool fs::CopyFileContents | ( | const std::string & | source, |
const std::string & | target ) |
References errorstream, and tracestream.
Referenced by CopyDir(), TestFileSys::testCopyFileContents(), and FileCache::updateCopyFile().
bool fs::CreateAllDirs | ( | const std::string & | path | ) |
References CreateDir(), PathExists(), and RemoveLastPathComponent().
Referenced by CopyDir(), create_userdata_path(), porting::createCacheDirTag(), FileCache::createDir(), ModStorageDatabaseFiles::endSave(), Client::initLocalMapSaving(), ModApiMainMenu::l_create_dir(), ModApiServer::l_get_mod_data_path(), ModApiUtil::l_mkdir(), loadGameConfAndInitWorld(), Database_SQLite3::openDatabase(), TestServerModManager::runTests(), and MapSettingsManager::saveMapMeta().
bool fs::CreateDir | ( | const std::string & | path | ) |
Referenced by PlayerDatabaseFiles::PlayerDatabaseFiles(), Server::Server(), create_userdata_path(), CreateAllDirs(), Client::makeScreenshot(), ServerEnvironment::migratePlayersDatabase(), TestServerModManager::runTests(), PlayerDatabaseFiles::savePlayer(), and TestFileSys::testRecursiveDelete().
std::string fs::CreateTempDir | ( | ) |
Returns path to securely-created temporary directory (will already exist when this function returns).
References DIR_DELIM, and TempPath().
Referenced by TestBase::getTestTempDirectory(), and ModApiMainMenu::l_get_temp_path().
std::string fs::CreateTempFile | ( | ) |
Returns path to securely-created temporary file (will already exist when this function returns).
References DIR_DELIM, and TempPath().
Referenced by ModApiMainMenu::l_get_temp_path().
bool fs::DeleteSingleFileOrEmptyDirectory | ( | const std::string & | path | ) |
References errorstream, and IsDir().
Referenced by Server::~Server(), GUIEngine::downloadFile(), ModApiUtil::l_rmdir(), ServerEnvironment::migratePlayersDatabase(), TestBan::reinitTestEnv(), PlayerDatabaseFiles::removePlayer(), TestAuthDatabase::runTests(), TestModStorageDatabase::runTests(), FileLogOutput::setFile(), Server::stepPendingDynMediaCallbacks(), and TestFileSys::testNonExist().
std::vector< DirListNode > fs::GetDirListing | ( | const std::string & | pathstring | ) |
References fs::DirListNode::dir, and fs::DirListNode::name.
Referenced by ServerMap::ServerMap(), CopyDir(), Server::fillMediaCache(), getAvailableGameIds(), getAvailableWorlds(), getModsInPath(), GetRecursiveSubPaths(), ModApiUtil::l_get_dir_list(), ModStorageDatabaseFiles::listMods(), PlayerDatabaseFiles::listPlayers(), RecursiveDeleteContent(), and Client::scanModSubfolder().
const char * fs::GetFilenameFromPath | ( | const char * | path | ) |
References DIR_DELIM_CHAR.
Referenced by ScriptApiSecurity::checkPathWithGamedef(), Server::dynamicAddMedia(), GUIEngine::getContentTranslations(), Server::init(), ModApiMainMenu::l_check_mod_configuration(), main(), and parseContentInfo().
std::vector< std::string > fs::GetRecursiveDirs | ( | const std::string & | dir | ) |
void fs::GetRecursiveDirs | ( | std::vector< std::string > & | dirs, |
const std::string & | dir ) |
References dir(), GetRecursiveSubPaths(), and IsDir().
Referenced by Server::fillMediaCache(), ServerModManager::getModsMediaPaths(), GetRecursiveDirs(), getTextureDirs(), and Server::init().
void fs::GetRecursiveSubPaths | ( | const std::string & | path, |
std::vector< std::string > & | dst, | ||
bool | list_files, | ||
const std::set< char > & | ignore ) |
References DIR_DELIM, GetDirListing(), and GetRecursiveSubPaths().
Referenced by GetRecursiveDirs(), and GetRecursiveSubPaths().
bool fs::IsDir | ( | const std::string & | path | ) |
Referenced by DeleteSingleFileOrEmptyDirectory(), ModStorageDatabaseFiles::endSave(), GetRecursiveDirs(), Client::initLocalMapSaving(), IsFile(), ModApiMainMenu::l_is_dir(), Client::migrateModStorage(), porting::open_directory(), TestFileSys::testNonExist(), and TestFileSys::testRecursiveDelete().
bool fs::IsDirDelimiter | ( | char | c | ) |
Referenced by PathStartsWith(), RemoveLastPathComponent(), RemoveRelativePathComponents(), and TestFileSys::testIsDirDelimiter().
bool fs::IsExecutable | ( | const std::string & | path | ) |
|
inline |
References IsDir(), and PathExists().
Referenced by getContentType(), sound::OpenALSoundManager::loadSoundFile(), sound::ProxySoundManager::loadSoundFile(), parseModContents(), TestBan::testCreate(), TestFileSys::testNonExist(), and TestFileSys::testRecursiveDelete().
bool fs::IsPathAbsolute | ( | const std::string & | path | ) |
Referenced by load_schematic(), Client::makeScreenshot(), and RecursiveDelete().
bool fs::MoveDir | ( | const std::string & | source, |
const std::string & | target ) |
References CopyDir(), errorstream, infostream, PathExists(), RecursiveDelete(), and Rename().
Referenced by ModApiMainMenu::l_copy_dir(), and ModApiUtil::l_mvdir().
bool fs::OpenStream | ( | std::filebuf & | stream, |
const char * | filename, | ||
std::ios::openmode | mode, | ||
bool | log_error, | ||
bool | log_warn ) |
Open a file buffer with error handling, commonly used with std::fstream.rdbuf()
.
stream | stream references, must not already be open |
filename | filename to open |
mode | mode bits (used as-is) |
log_error | log failure to errorstream? |
log_warn | log failure to warningstream? |
References errorstream, LAST_OS_ERROR, and warningstream.
Referenced by open_ifstream(), open_ofstream(), FileLogOutput::setFile(), and TestFileSys::testNonExist().
bool fs::PathExists | ( | const std::string & | path | ) |
Referenced by ServerMap::ServerMap(), CopyDir(), create_userdata_path(), CreateAllDirs(), porting::createCacheDirTag(), FileCache::exists(), findLocaleFileWithExtension(), findSubgame(), findWorldSubgame(), getAvailableWorlds(), getImagePath(), ModStorageDatabaseFiles::getOrCreateJson(), getShaderPath(), getWorldExists(), getWorldGameId(), RollbackManager::initDatabase(), porting::initializePaths(), IsFile(), ClientLauncher::launch_game(), loadGameConfAndInitWorld(), ServerEnvironment::loadMeta(), Client::makeScreenshot(), ServerEnvironment::migrateAuthDatabase(), porting::migrateCachePath(), MoveDir(), Database_SQLite3::openDatabase(), PlayerDatabaseFiles::savePlayer(), GUIEngine::setTexture(), TestMapSettingsManager::testMapMetaFailures(), and TestFileSys::testSafeWriteToFile().
bool fs::PathStartsWith | ( | const std::string & | path, |
const std::string & | prefix ) |
References FILESYS_CASE_INSENSITIVE, IsDirDelimiter(), and my_tolower().
Referenced by ScriptApiSecurity::checkPathWithGamedef(), MainMenuScripting::mayModifyPath(), and TestFileSys::testPathStartsWith().
bool fs::ReadFile | ( | const std::string & | path, |
std::string & | out, | ||
bool | log_error ) |
References open_ifstream().
Referenced by Server::addMediaFile(), GUIEngine::getContentTranslations(), Server::getTranslationLanguage(), parseContentInfo(), parseModContents(), read_translation_file(), SourceShaderCache::readFile(), ShadowRenderer::readShaderFile(), Client::scanModSubfolder(), Server::sendRequestedMedia(), TestFileSys::testCopyFileContents(), TestMapSettingsManager::testMapSettingsManager(), TestFileSys::testNonExist(), and TestFileSys::testSafeWriteToFile().
bool fs::RecursiveDelete | ( | const std::string & | path | ) |
References errorstream, infostream, and IsPathAbsolute().
Referenced by ModApiMainMenu::l_delete_dir(), ModApiMainMenu::l_delete_world(), ModApiUtil::l_rmdir(), porting::migrateCachePath(), MoveDir(), RecursiveDeleteContent(), TestModStorageDatabase::runTests(), TestBase::testModule(), and TestFileSys::testRecursiveDelete().
bool fs::RecursiveDeleteContent | ( | const std::string & | path | ) |
References DIR_DELIM, errorstream, GetDirListing(), infostream, RecursiveDelete(), and trim().
std::string fs::RemoveLastPathComponent | ( | const std::string & | path, |
std::string * | removed, | ||
int | count ) |
References DIR_DELIM, and IsDirDelimiter().
Referenced by ScriptApiSecurity::checkPath(), CreateAllDirs(), MapSettingsManager::saveMapMeta(), TestFileSys::testRemoveLastPathComponent(), and TestFileSys::testRemoveLastPathComponentWithTrailingDelimiter().
std::string fs::RemoveRelativePathComponents | ( | std::string | path | ) |
References DIR_DELIM, and IsDirDelimiter().
Referenced by ModApiMainMenu::l_get_cache_path(), ModApiMainMenu::l_get_clientmodpath(), ModApiMainMenu::l_get_gamepath(), ModApiMainMenu::l_get_modpath(), ModApiMainMenu::l_get_modpaths(), ModApiMainMenu::l_get_texturepath(), ModApiMainMenu::l_get_texturepath_share(), ModApiMainMenu::l_get_user_path(), MainMenuScripting::mayModifyPath(), and TestFileSys::testRemoveRelativePathComponent().
bool fs::Rename | ( | const std::string & | from, |
const std::string & | to ) |
Referenced by ServerEnvironment::migrateAuthDatabase(), porting::migrateCachePath(), Client::migrateModStorage(), Server::migrateModStorageDatabase(), ServerEnvironment::migratePlayersDatabase(), MoveDir(), FileLogOutput::setFile(), and TestFileSys::testNonExist().
bool fs::safeWriteToFile | ( | const std::string & | path, |
std::string_view | content ) |
References errorstream, itos(), LAST_OS_ERROR, open_ofstream(), remove(), and sleep_ms.
Referenced by ModStorageDatabaseFiles::endSave(), ModApiUtil::l_safe_file_write(), LuaAreaStore::l_to_file(), BanManager::save(), ServerEnvironment::saveMeta(), PlayerDatabaseFiles::savePlayer(), Schematic::saveSchematicToFile(), TestFileSys::testSafeWriteToFile(), Settings::updateConfigFile(), and AuthDatabaseFiles::writeAuthFile().
std::string fs::TempPath | ( | ) |
Returns path to temp directory.
You probably don't want to use this directly, see CreateTempFile
or CreateTempDir
.
References DIR_DELIM, and porting::path_cache.
Referenced by CreateTempDir(), CreateTempFile(), and MainMenuScripting::mayModifyPath().