Ring Daemon 16.0.0
|
Classes | |
struct | ArchiveStorageData |
Functions | |
int | accessFile (const std::string &file, int mode) |
Windows compatibility wrapper for checking read-only attribute. | |
bool | createFileLink (const std::filesystem::path &linkFile, const std::filesystem::path &target, bool hard) |
bool | createHardlink (const std::filesystem::path &linkFile, const std::filesystem::path &target) |
bool | createSymlink (const std::filesystem::path &linkFile, const std::filesystem::path &target) |
bool | eraseFile (const std::string &path, bool dosync) |
bool | eraseFile_posix (const std::string &path, bool dosync) |
std::string | expand_path (const std::string &path) |
Expand the given path. | |
const std::filesystem::path & | get_cache_dir () |
std::filesystem::path | get_cache_dir (const char *pkg) |
const std::filesystem::path & | get_config_dir () |
std::filesystem::path | get_config_dir (const char *pkg) |
const std::filesystem::path & | get_data_dir () |
std::filesystem::path | get_data_dir (const char *pkg) |
const std::filesystem::path & | get_home_dir () |
std::filesystem::path | get_home_dir_impl () |
const std::filesystem::path & | get_resource_dir_path () |
Get the resource directory path that was set with set_resource_dir_path. | |
std::string | 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 | getFileExtension (std::string_view filename) |
std::filesystem::path | getFullPath (const std::filesystem::path &base, const std::filesystem::path &path) |
If path is relative, it is appended to base. | |
bool | isDirectoryWritable (const std::string &directory) |
bool | isPathRelative (const std::filesystem::path &path) |
uint64_t | lastWriteTimeInSeconds (const std::filesystem::path &filePath) |
Return the last write time (epoch time) of a given file path (in seconds). | |
std::vector< uint8_t > | loadCacheFile (const std::filesystem::path &path, std::chrono::system_clock::duration maxAge) |
std::string | loadCacheTextFile (const std::filesystem::path &path, std::chrono::system_clock::duration maxAge) |
std::vector< uint8_t > | loadFile (const std::filesystem::path &path, const std::filesystem::path &default_dir={}) |
Read the full content of a file at path. | |
std::string | loadTextFile (const std::filesystem::path &path, const std::filesystem::path &default_dir) |
ArchiveStorageData | readArchive (const std::filesystem::path &path, std::string_view scheme, const std::string &pwd) |
int | remove (const std::filesystem::path &path, bool erase) |
void | saveFile (const std::filesystem::path &path, const std::vector< uint8_t > &data, mode_t mode=0644) |
void | saveFile (const std::filesystem::path &path, const uint8_t *data, size_t data_size, mode_t mode=0644) |
void | saveFile (const std::filesystem::path &path, const uint8_t *data, size_t data_size, mode_t UNUSED mode) |
void | set_resource_dir_path (const std::filesystem::path &resourceDirPath) |
Set the program's resource directory path. | |
std::string | sha3File (const std::filesystem::path &path) |
std::string | sha3sum (const std::vector< uint8_t > &buffer) |
std::string | sha3sum (const uint8_t *data, size_t size) |
int64_t | size (const std::filesystem::path &path) |
bool | 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 constexpr auto | ARCHIVE_AUTH_SCHEME_KEY = "key"sv |
static constexpr auto | ARCHIVE_AUTH_SCHEME_NONE = ""sv |
static constexpr auto | ARCHIVE_AUTH_SCHEME_PASSWORD = "password"sv |
static std::filesystem::path | resource_dir_path |
Windows compatibility wrapper for checking read-only attribute.
Definition at line 819 of file fileutils.cpp.
References jami::emitSignal().
Referenced by isDirectoryWritable().
bool jami::fileutils::createFileLink | ( | const std::filesystem::path & | linkFile, |
const std::filesystem::path & | target, | ||
bool | hard | ||
) |
Definition at line 216 of file fileutils.cpp.
References createHardlink(), createSymlink(), and jami::emitSignal().
bool jami::fileutils::createHardlink | ( | const std::filesystem::path & | linkFile, |
const std::filesystem::path & | target | ||
) |
Definition at line 202 of file fileutils.cpp.
References jami::emitSignal(), JAMI_LOG, and JAMI_WARNING.
Referenced by createFileLink().
bool jami::fileutils::createSymlink | ( | const std::filesystem::path & | linkFile, |
const std::filesystem::path & | target | ||
) |
Definition at line 188 of file fileutils.cpp.
References jami::emitSignal(), JAMI_LOG, and JAMI_WARNING.
Referenced by createFileLink().
Definition at line 731 of file fileutils.cpp.
References jami::emitSignal(), and eraseFile_posix().
Referenced by remove().
Definition at line 687 of file fileutils.cpp.
References jami::emitSignal(), JAMI_WARN, JAMI_WARNING, S_IWGRP, and S_IWUSR.
Referenced by eraseFile().
std::string jami::fileutils::expand_path | ( | const std::string & | path | ) |
Expand the given path.
path | The path to be expanded. |
Definition at line 139 of file fileutils.cpp.
References jami::emitSignal(), and JAMI_ERR.
Referenced by jami::AudioPreference::setRecordPath().
const std::filesystem::path & jami::fileutils::get_cache_dir | ( | ) |
Definition at line 491 of file fileutils.cpp.
References jami::emitSignal(), and get_cache_dir().
Referenced by jami::SIPAccountBase::flush(), get_cache_dir(), jami::Manager::init(), jami::SIPAccountBase::loadConfig(), and jami::NameDirectory::NameDirectory().
Definition at line 465 of file fileutils.cpp.
References jami::emitSignal(), get_home_dir(), jami::to_string(), and XDG_CACHE_HOME.
const std::filesystem::path & jami::fileutils::get_config_dir | ( | ) |
Definition at line 615 of file fileutils.cpp.
References jami::emitSignal(), and get_config_dir().
Referenced by get_config_dir(), jami::Manager::init(), jami::MediaEncoder::readConfig(), and jami::Manager::ManagerPimpl::retrieveConfigPath().
Definition at line 580 of file fileutils.cpp.
References jami::emitSignal(), get_home_dir(), JAMI_DBG, and XDG_CONFIG_HOME.
const std::filesystem::path & jami::fileutils::get_data_dir | ( | ) |
Definition at line 573 of file fileutils.cpp.
References jami::emitSignal(), and get_data_dir().
Referenced by jami::OutgoingFile::cancel(), jami::ConversationRepository::cloneConversation(), jami::ConversationRepository::createConversation(), jami::ConversationModule::Impl::editMessage(), get_data_dir(), jami::PluginPreferencesUtils::getAllowDenyListsPath(), jami::JamiPluginManager::getInstalledPlugins(), jami::GitServer::GitServer(), jami::ConversationRepository::Impl::Impl(), jami::Conversation::Impl::Impl(), jami::TransferManager::Impl::Impl(), jami::Manager::init(), jami::Conversation::Impl::init(), jami::JamiPluginManager::installPlugin(), jami::Manager::loadAccountAndConversation(), jami::Manager::loadAccountMap(), jami::ConversationModule::loadConversations(), jami::ConversationModule::Impl::loadMetadata(), jami::ConversationModule::loadSingleConversation(), jami::Conversation::Impl::repoPath(), jami::ConversationRepository::Impl::repository(), jami::ConversationModule::saveConvInfos(), jami::ConversationModule::saveConvRequests(), jami::ConversationModule::Impl::saveMetadata(), jami::TransferChannelHandler::TransferChannelHandler(), jami::JamiPluginManager::uninstallPlugin(), and jami::PluginPreferencesUtils::valuesFilePath().
Definition at line 541 of file fileutils.cpp.
References jami::emitSignal(), get_home_dir(), and XDG_DATA_HOME.
const std::filesystem::path & jami::fileutils::get_home_dir | ( | ) |
Definition at line 534 of file fileutils.cpp.
References jami::emitSignal(), and get_home_dir_impl().
Referenced by get_cache_dir(), get_config_dir(), get_data_dir(), and jami::Recordable::toggleRecording().
std::filesystem::path jami::fileutils::get_home_dir_impl | ( | ) |
Definition at line 498 of file fileutils.cpp.
References jami::emitSignal(), PROTECTED_GETENV, and jami::to_string().
Referenced by get_home_dir().
const std::filesystem::path & jami::fileutils::get_resource_dir_path | ( | ) |
Get the resource directory path that was set with set_resource_dir_path.
Definition at line 132 of file fileutils.cpp.
References jami::emitSignal(), and resource_dir_path.
Referenced by jami::Account::loadConfig().
If path is contained in base, return the suffix, otherwise return the full path.
base | must not finish with DIR_SEPARATOR_STR, can be empty |
path | the path |
Definition at line 251 of file fileutils.cpp.
References DIR_SEPARATOR_STR, and jami::emitSignal().
std::string_view jami::fileutils::getFileExtension | ( | std::string_view | filename | ) |
Definition at line 233 of file fileutils.cpp.
References jami::emitSignal().
Referenced by jami::ConversationRepository::Impl::convCommitToMap().
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.
Definition at line 263 of file fileutils.cpp.
References jami::emitSignal(), and isPathRelative().
Referenced by jami::Conversation::Impl::isAdmin(), jami::ConversationRepository::join(), jami::Account::loadConfig(), loadFile(), loadTextFile(), jami::parsePath(), jami::yaml_utils::parsePath(), jami::yaml_utils::parsePathOptional(), jami::ConversationRepository::resolveVote(), jami::JamiAccountConfig::toMap(), jami::ConversationRepository::voteKick(), and jami::ConversationRepository::voteUnban().
Definition at line 182 of file fileutils.cpp.
References accessFile(), and jami::emitSignal().
Referenced by jami::AudioPreference::setRecordPath().
Definition at line 245 of file fileutils.cpp.
References jami::emitSignal().
Referenced by getFullPath().
Return the last write time (epoch time) of a given file path (in seconds).
Definition at line 829 of file fileutils.cpp.
References jami::emitSignal(), and JAMI_WARNING.
Referenced by jami::Conversation::preferences(), and jami::Conversation::updatePreferences().
std::vector< uint8_t > jami::fileutils::loadCacheFile | ( | const std::filesystem::path & | path, |
std::chrono::system_clock::duration | maxAge | ||
) |
Definition at line 322 of file fileutils.cpp.
References jami::emitSignal(), and JAMI_LOG.
std::string jami::fileutils::loadCacheTextFile | ( | const std::filesystem::path & | path, |
std::chrono::system_clock::duration | maxAge | ||
) |
Definition at line 338 of file fileutils.cpp.
References jami::emitSignal(), JAMI_LOG, and loadTextFile().
std::vector< uint8_t > jami::fileutils::loadFile | ( | const std::filesystem::path & | path, |
const std::filesystem::path & | default_dir = {} |
||
) |
Read the full content of a file at path.
If path is relative, it is appended to default_dir.
Definition at line 270 of file fileutils.cpp.
References jami::emitSignal(), and getFullPath().
Referenced by jami::ConversationRepository::Impl::devices(), libjami::getCertificateDetailsPath(), jami::ConversationRepository::infos(), jami::ConversationRepository::leave(), jami::Conversation::Impl::loadActiveCalls(), jami::Conversation::Impl::loadHostedCalls(), jami::ConversationRepository::Impl::loadMembers(), jami::ConversationModule::Impl::loadMetadata(), jami::Conversation::Impl::loadStatus(), jami::TransferManager::Impl::loadWaiting(), jami::Conversation::preferences(), jami::PluginUtils::readPluginCertificate(), jami::ConversationRepository::Impl::resolveBan(), jami::tls::TlsValidator::TlsValidator(), jami::SIPAccount::updateProfile(), jami::ConversationRepository::Impl::uriFromDevice(), jami::ConversationRepository::Impl::validateDevice(), and jami::Conversation::vCard().
std::string jami::fileutils::loadTextFile | ( | const std::filesystem::path & | path, |
const std::filesystem::path & | default_dir | ||
) |
Definition at line 276 of file fileutils.cpp.
References jami::emitSignal(), getFullPath(), and size().
Referenced by jami::Account::getProfileVcard(), and loadCacheTextFile().
ArchiveStorageData jami::fileutils::readArchive | ( | const std::filesystem::path & | path, |
std::string_view | scheme, | ||
const std::string & | pwd | ||
) |
Definition at line 354 of file fileutils.cpp.
References ARCHIVE_AUTH_SCHEME_KEY, ARCHIVE_AUTH_SCHEME_PASSWORD, jami::base64::decode(), jami::archiver::decompress(), jami::emitSignal(), JAMI_ERROR, JAMI_LOG, JAMI_WARNING, and jami::fileutils::ArchiveStorageData::salt.
Referenced by jami::AccountArchive::load().
Definition at line 741 of file fileutils.cpp.
References jami::emitSignal(), and eraseFile().
|
inline |
Definition at line 114 of file fileutils.h.
References saveFile().
void jami::fileutils::saveFile | ( | const std::filesystem::path & | path, |
const uint8_t * | data, | ||
size_t | data_size, | ||
mode_t | mode = 0644 |
||
) |
void jami::fileutils::saveFile | ( | const std::filesystem::path & | path, |
const uint8_t * | data, | ||
size_t | data_size, | ||
mode_t UNUSED | mode | ||
) |
Definition at line 303 of file fileutils.cpp.
References jami::emitSignal(), JAMI_ERROR, and JAMI_WARNING.
Referenced by saveFile(), and writeArchive().
LIBJAMI_PUBLIC void jami::fileutils::set_resource_dir_path | ( | const std::filesystem::path & | resourceDirPath | ) |
Set the program's resource directory path.
This is used for clients that may be installed in different locations and are deployed with ringtones and other resources in an application relative directory.
resource_dir_path | The path to the ringtone directory. |
Definition at line 126 of file fileutils.cpp.
References jami::emitSignal(), and resource_dir_path.
Referenced by libjami::setResourceDirPath().
std::string jami::fileutils::sha3File | ( | const std::filesystem::path & | path | ) |
Definition at line 770 of file fileutils.cpp.
References jami::emitSignal(), and JAMI_ERROR.
Referenced by jami::ConversationModule::onFileChannelRequest(), and jami::IncomingFile::process().
Definition at line 808 of file fileutils.cpp.
References jami::emitSignal(), and size().
Definition at line 756 of file fileutils.cpp.
References jami::emitSignal(), and size().
Referenced by loadTextFile(), sha3sum(), and size().
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 | ||
) |
Definition at line 425 of file fileutils.cpp.
References ARCHIVE_AUTH_SCHEME_KEY, ARCHIVE_AUTH_SCHEME_NONE, ARCHIVE_AUTH_SCHEME_PASSWORD, jami::archiver::compress(), jami::archiver::compressGzip(), jami::base64::decode(), jami::emitSignal(), JAMI_ERROR, JAMI_LOG, JAMI_WARNING, and saveFile().
Referenced by jami::AccountArchive::save().
Definition at line 126 of file fileutils.h.
Referenced by readArchive(), and writeArchive().
Definition at line 124 of file fileutils.h.
Referenced by writeArchive().
Definition at line 125 of file fileutils.h.
Referenced by readArchive(), and writeArchive().
|
static |
Definition at line 123 of file fileutils.cpp.
Referenced by get_resource_dir_path(), and set_resource_dir_path().