Ring Daemon 16.0.0
Loading...
Searching...
No Matches
fileutils.cpp File Reference
Include dependency graph for fileutils.cpp:

Go to the source code of this file.

Namespaces

namespace  jami
 
namespace  jami::fileutils
 

Macros

#define ERASE_BLOCK   4096
 
#define PIDFILE   ".ring.pid"
 
#define PROTECTED_GETENV(str)
 
#define XDG_CACHE_HOME   (PROTECTED_GETENV("XDG_CACHE_HOME"))
 
#define XDG_CONFIG_HOME   (PROTECTED_GETENV("XDG_CONFIG_HOME"))
 
#define XDG_DATA_HOME   (PROTECTED_GETENV("XDG_DATA_HOME"))
 

Functions

int jami::fileutils::accessFile (const std::string &file, int mode)
 Windows compatibility wrapper for checking read-only attribute.
 
bool jami::fileutils::createFileLink (const std::filesystem::path &linkFile, const std::filesystem::path &target, bool hard)
 
bool jami::fileutils::createHardlink (const std::filesystem::path &linkFile, const std::filesystem::path &target)
 
bool jami::fileutils::createSymlink (const std::filesystem::path &linkFile, const std::filesystem::path &target)
 
bool jami::fileutils::eraseFile (const std::string &path, bool dosync)
 
bool jami::fileutils::eraseFile_posix (const std::string &path, bool dosync)
 
std::string jami::fileutils::expand_path (const std::string &path)
 Expand the given path.
 
const std::filesystem::path & jami::fileutils::get_cache_dir ()
 
std::filesystem::path jami::fileutils::get_cache_dir (const char *pkg)
 
const std::filesystem::path & jami::fileutils::get_config_dir ()
 
std::filesystem::path jami::fileutils::get_config_dir (const char *pkg)
 
const std::filesystem::path & jami::fileutils::get_data_dir ()
 
std::filesystem::path jami::fileutils::get_data_dir (const char *pkg)
 
const std::filesystem::path & jami::fileutils::get_home_dir ()
 
std::filesystem::path jami::fileutils::get_home_dir_impl ()
 
const std::filesystem::path & jami::fileutils::get_resource_dir_path ()
 Get the resource directory path that was set with set_resource_dir_path.
 
std::string jami::fileutils::getCleanPath (const std::string &base, const std::string &path)
 If path is contained in base, return the suffix, otherwise return the full path.
 
std::string_view jami::fileutils::getFileExtension (std::string_view filename)
 
std::filesystem::path jami::fileutils::getFullPath (const std::filesystem::path &base, const std::filesystem::path &path)
 If path is relative, it is appended to base.
 
bool jami::fileutils::isDirectoryWritable (const std::string &directory)
 
bool jami::fileutils::isPathRelative (const std::filesystem::path &path)
 
uint64_t jami::fileutils::lastWriteTimeInSeconds (const std::filesystem::path &filePath)
 Return the last write time (epoch time) of a given file path (in seconds).
 
std::vector< uint8_tjami::fileutils::loadCacheFile (const std::filesystem::path &path, std::chrono::system_clock::duration maxAge)
 
std::string jami::fileutils::loadCacheTextFile (const std::filesystem::path &path, std::chrono::system_clock::duration maxAge)
 
std::vector< uint8_tjami::fileutils::loadFile (const std::filesystem::path &path, const std::filesystem::path &default_dir={})
 Read the full content of a file at path.
 
std::string jami::fileutils::loadTextFile (const std::filesystem::path &path, const std::filesystem::path &default_dir)
 
ArchiveStorageData jami::fileutils::readArchive (const std::filesystem::path &path, std::string_view scheme, const std::string &pwd)
 
int jami::fileutils::remove (const std::filesystem::path &path, bool erase)
 
void jami::fileutils::saveFile (const std::filesystem::path &path, const uint8_t *data, size_t data_size, mode_t UNUSED mode)
 
void jami::fileutils::set_resource_dir_path (const std::filesystem::path &resourceDirPath)
 Set the program's resource directory path.
 
std::string jami::fileutils::sha3File (const std::filesystem::path &path)
 
std::string jami::fileutils::sha3sum (const uint8_t *data, size_t size)
 
int64_t jami::fileutils::size (const std::filesystem::path &path)
 
bool jami::fileutils::writeArchive (const std::string &archive_str, const std::filesystem::path &path, std::string_view scheme, const std::string &password, const std::vector< uint8_t > &password_salt)
 

Variables

static std::filesystem::path jami::fileutils::resource_dir_path
 

Macro Definition Documentation

◆ ERASE_BLOCK

#define ERASE_BLOCK   4096

Definition at line 118 of file fileutils.cpp.

◆ PIDFILE

#define PIDFILE   ".ring.pid"

Definition at line 117 of file fileutils.cpp.

◆ PROTECTED_GETENV

#define PROTECTED_GETENV (   str)
Value:
({ \
char* envvar_ = getenv((str)); \
envvar_ ? envvar_ : ""; \
})

Definition at line 88 of file fileutils.cpp.

◆ XDG_CACHE_HOME

#define XDG_CACHE_HOME   (PROTECTED_GETENV("XDG_CACHE_HOME"))

Definition at line 96 of file fileutils.cpp.

◆ XDG_CONFIG_HOME

#define XDG_CONFIG_HOME   (PROTECTED_GETENV("XDG_CONFIG_HOME"))

Definition at line 95 of file fileutils.cpp.

◆ XDG_DATA_HOME

#define XDG_DATA_HOME   (PROTECTED_GETENV("XDG_DATA_HOME"))

Definition at line 94 of file fileutils.cpp.