Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
filesys.h File Reference
#include "config.h"
#include <set>
#include <string>
#include <string_view>
#include <vector>
#include <fstream>
+ Include dependency graph for filesys.h:

Go to the source code of this file.

Classes

struct  fs::DirListNode
 

Namespaces

namespace  irr
 
namespace  irr::io
 
namespace  fs
 

Macros

#define DIR_DELIM   "/"
 
#define DIR_DELIM_CHAR   '/'
 
#define FILESYS_CASE_INSENSITIVE   false
 
#define PATH_DELIM   ":"
 

Functions

std::vector< DirListNodefs::GetDirListing (const std::string &pathstring)
 
bool fs::CreateDir (const std::string &path)
 
bool fs::PathExists (const std::string &path)
 
bool fs::IsPathAbsolute (const std::string &path)
 
bool fs::IsDir (const std::string &path)
 
bool fs::IsExecutable (const std::string &path)
 
bool fs::IsFile (const std::string &path)
 
bool fs::IsDirDelimiter (char c)
 
bool fs::RecursiveDelete (const std::string &path)
 
bool fs::DeleteSingleFileOrEmptyDirectory (const std::string &path)
 
std::string fs::TempPath ()
 Returns path to temp directory.
 
std::string fs::CreateTempFile ()
 Returns path to securely-created temporary file (will already exist when this function returns).
 
std::string fs::CreateTempDir ()
 Returns path to securely-created temporary directory (will already exist when this function returns).
 
void fs::GetRecursiveDirs (std::vector< std::string > &dirs, const std::string &dir)
 
std::vector< std::string > fs::GetRecursiveDirs (const std::string &dir)
 
void fs::GetRecursiveSubPaths (const std::string &path, std::vector< std::string > &dst, bool list_files, const std::set< char > &ignore)
 
bool fs::RecursiveDeleteContent (const std::string &path)
 
bool fs::CreateAllDirs (const std::string &path)
 
bool fs::CopyFileContents (const std::string &source, const std::string &target)
 
bool fs::CopyDir (const std::string &source, const std::string &target)
 
bool fs::MoveDir (const std::string &source, const std::string &target)
 
bool fs::PathStartsWith (const std::string &path, const std::string &prefix)
 
std::string fs::RemoveLastPathComponent (const std::string &path, std::string *removed, int count)
 
std::string fs::RemoveRelativePathComponents (std::string path)
 
std::string fs::AbsolutePath (const std::string &path)
 
const char * fs::GetFilenameFromPath (const char *path)
 
bool fs::safeWriteToFile (const std::string &path, std::string_view content)
 
bool fs::ReadFile (const std::string &path, std::string &out, bool log_error)
 
bool fs::Rename (const std::string &from, const std::string &to)
 
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().
 
std::ofstream open_ofstream (const char *name, bool log, std::ios::openmode mode=std::ios::openmode())
 Helper function to open an output file stream (= writing).
 
std::ifstream open_ifstream (const char *name, bool log, std::ios::openmode mode=std::ios::openmode())
 Helper function to open an input file stream (= reading).
 

Macro Definition Documentation

◆ DIR_DELIM

#define DIR_DELIM   "/"

Referenced by AuthDatabaseLevelDB::AuthDatabaseLevelDB(), Client::Client(), Database_LevelDB::Database_LevelDB(), PlayerDatabaseLevelDB::PlayerDatabaseLevelDB(), RenderingEngine::RenderingEngine(), RollbackManager::RollbackManager(), ScriptApiBase::ScriptApiBase(), Server::Server(), ServerMap::ServerMap(), ServerModManager::ServerModManager(), MenuMusicFetcher::addThePaths(), SoundFallbackPathProvider::addThePaths(), Client::afterContentReceived(), auto_select_world(), ScriptApiSecurity::checkPath(), ScriptApiSecurity::checkPathWithGamedef(), porting::cleanupAndroid(), fs::CopyDir(), porting::createCacheDirTag(), fs::CreateTempDir(), fs::CreateTempFile(), ModStorageDatabaseFiles::endSave(), FileCache::exists(), Server::fillMediaCache(), findLocaleFileInMods(), findSubgame(), findWorldSubgame(), SourceShaderCache::get(), getAvailableGameIds(), getAvailableWorlds(), Client::getBuiltinLuaPath(), Server::getBuiltinLuaPath(), Client::getClientModsLuaPath(), GUIEngine::getContentTranslations(), getContentType(), porting::getDataPath(), getMediaCacheDir(), getModsInPath(), ServerModManager::getModsMediaPaths(), ModStorageDatabaseFiles::getOrCreateJson(), SourceShaderCache::getOrLoad(), fs::GetRecursiveSubPaths(), getShaderPath(), getSubgameSpec(), TestBase::getTestTempFile(), getTexturePath(), getWorldExists(), getWorldGameId(), getWorldName(), Server::init(), ServerEnvironment::init(), init_log_streams(), porting::initializePaths(), EmergeThread::initScripting(), SourceShaderCache::insert(), ModApiMainMenu::l_check_mod_configuration(), ModApiMainMenu::l_create_world(), ModApiUtil::l_get_builtin_path(), ModApiMainMenu::l_get_clientmodpath(), ModApiMainMenu::l_get_gamepath(), ModApiMainMenu::l_get_games(), ModApiServer::l_get_mod_data_path(), ModApiMainMenu::l_get_modpath(), ModApiMainMenu::l_get_modpaths(), ModApiMainMenu::l_get_texturepath(), ModApiMainMenu::l_get_texturepath_share(), PlayerDatabaseFiles::listPlayers(), FileCache::load(), load_schematic(), ServerScripting::loadBuiltin(), loadGameConfAndInitWorld(), GUIEngine::loadMainMenuScript(), ServerEnvironment::loadMeta(), Client::loadMods(), ServerModManager::loadMods(), PlayerDatabaseFiles::loadPlayer(), Client::makeScreenshot(), MainMenuScripting::mayModifyPath(), migrate_map_database(), ServerEnvironment::migrateAuthDatabase(), porting::migrateCachePath(), Client::migrateModStorage(), Server::migrateModStorageDatabase(), ServerEnvironment::migratePlayersDatabase(), Database_SQLite3::openDatabase(), Server::openModStorageDatabase(), ServerEnvironment::openPlayerDatabase(), p(), parseContentInfo(), parseModContents(), AsyncEngine::prepareEnvironment(), read_config_file(), read_translation_file(), AuthDatabaseFiles::readAuthFile(), recompress_map_database(), fs::RecursiveDeleteContent(), TestBan::reinitTestEnv(), fs::RemoveLastPathComponent(), PlayerDatabaseFiles::removePlayer(), fs::RemoveRelativePathComponents(), TestAuthDatabase::runTests(), TestModStorageDatabase::runTests(), TestMoveAction::runTests(), TestSAO::runTests(), TestServerModManager::runTests(), ServerEnvironment::saveMeta(), PlayerDatabaseFiles::savePlayer(), Client::scanModSubfolder(), set_default_settings(), porting::setSystemPaths(), fs::TempPath(), TEST_CASE(), TestFileSys::testCopyFileContents(), TestServerModManager::testCreation(), TestServerModManager::testGetModMediaPaths(), TestServerModManager::testGetModMediaPathsWrongDir(), TestServerModManager::testGetModNamesWrongDir(), TestServerModManager::testGetModsWrongDir(), TestMapSettingsManager::testMapMetaSaveLoad(), TestFileSys::testRecursiveDelete(), FileCache::update(), FileCache::updateCopyFile(), and AuthDatabaseFiles::writeAuthFile().

◆ DIR_DELIM_CHAR

◆ FILESYS_CASE_INSENSITIVE

#define FILESYS_CASE_INSENSITIVE   false

◆ PATH_DELIM

#define PATH_DELIM   ":"

Function Documentation

◆ open_ifstream()

std::ifstream open_ifstream ( const char * name,
bool log,
std::ios::openmode mode = std::ios::openmode() )
inline

Helper function to open an input file stream (= reading).

For compatibility with fopen() binary mode is always set. Use fs::OpenStream for more control.

Parameters
namefile name
logif true, failure to open the file will be logged to errorstream
modeadditional mode bits (e.g. std::ios::ate)
Returns
file stream, will be !good in case of error

References fs::OpenStream().

Referenced by TextureOverrideSource::TextureOverrideSource(), ModStorageDatabaseFiles::getOrCreateJson(), LuaAreaStore::l_from_file(), PlayerDatabaseFiles::listPlayers(), BanManager::load(), FileCache::loadByPath(), MapSettingsManager::loadMapMeta(), PlayerDatabaseFiles::loadPlayer(), Schematic::loadSchematicFromFile(), AuthDatabaseFiles::readAuthFile(), fs::ReadFile(), PlayerDatabaseFiles::removePlayer(), PlayerDatabaseFiles::savePlayer(), and TestFileSys::testNonExist().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ open_ofstream()

std::ofstream open_ofstream ( const char * name,
bool log,
std::ios::openmode mode = std::ios::openmode() )
inline

Helper function to open an output file stream (= writing).

For compatibility with fopen() binary mode and truncate are always set. Use fs::OpenStream for more control.

Parameters
namefile name
logif true, failure to open the file will be logged to errorstream
modeadditional mode bits (e.g. std::ios::app)
Returns
file stream, will be !good in case of error

References fs::OpenStream().

Referenced by porting::createCacheDirTag(), GUIEngine::downloadFile(), fs::safeWriteToFile(), TestFileSys::testRecursiveDelete(), and FileCache::updateByPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: