20#include <dhtnet/fileutils.h>
33#define DIR_SEPARATOR_STR "/"
34#define DIR_SEPARATOR_CH '/'
35#define DIR_SEPARATOR_STR_ESC "\\/"
37#define mode_t unsigned
38#define DIR_SEPARATOR_STR "\\"
39#define DIR_SEPARATOR_CH '\\'
40#define DIR_SEPARATOR_STR_ESC "//*"
46using namespace std::literals;
85std::string
getCleanPath(
const std::string& base,
const std::string& path);
89std::filesystem::path
getFullPath(
const std::filesystem::path& base,
90 const std::filesystem::path& path);
93 const std::filesystem::path&
dest,
104std::vector<uint8_t>
loadFile(
const std::filesystem::path& path,
106std::string
loadTextFile(
const std::filesystem::path& path,
114saveFile(
const std::filesystem::path& path,
const std::vector<uint8_t>& data,
mode_t mode = 0644)
116 saveFile(path, data.data(), data.size(), mode);
119std::vector<uint8_t>
loadCacheFile(
const std::filesystem::path& path,
120 std::chrono::system_clock::duration
maxAge);
122 std::chrono::system_clock::duration
maxAge);
134 std::string_view scheme,
135 const std::string&
pwd);
138 const std::filesystem::path& path,
139 std::string_view scheme,
140 const std::string& password = {},
141 const std::vector<uint8_t>& password_salt = {});
145std::string
sha3File(
const std::filesystem::path& path);
const std::filesystem::path & get_data_dir()
void set_resource_dir_path(const std::filesystem::path &resourceDirPath)
Set the program's resource directory path.
std::vector< uint8_t > loadCacheFile(const std::filesystem::path &path, std::chrono::system_clock::duration maxAge)
static constexpr auto ARCHIVE_AUTH_SCHEME_PASSWORD
int accessFile(const std::string &file, int mode)
Windows compatibility wrapper for checking read-only attribute.
std::string sha3File(const std::filesystem::path &path)
bool createFileLink(const std::filesystem::path &linkFile, const std::filesystem::path &target, bool hard)
void saveFile(const std::filesystem::path &path, const uint8_t *data, size_t data_size, mode_t UNUSED mode)
static constexpr auto ARCHIVE_AUTH_SCHEME_NONE
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.
int64_t size(const std::filesystem::path &path)
ArchiveStorageData readArchive(const std::filesystem::path &path, std::string_view scheme, const std::string &pwd)
const std::filesystem::path & get_config_dir()
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.
uint64_t lastWriteTimeInSeconds(const std::filesystem::path &filePath)
Return the last write time (epoch time) of a given file path (in seconds).
static constexpr auto ARCHIVE_AUTH_SCHEME_KEY
bool isPathRelative(const std::filesystem::path &path)
std::string sha3sum(const uint8_t *data, size_t size)
std::string_view getFileExtension(std::string_view filename)
const std::filesystem::path & get_cache_dir()
bool isDirectoryWritable(const std::string &directory)
std::filesystem::path getFullPath(const std::filesystem::path &base, const std::filesystem::path &path)
If path is relative, it is appended to base.
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)
const std::filesystem::path & get_resource_dir_path()
Get the resource directory path that was set with set_resource_dir_path.
std::string expand_path(const std::string &path)
Expand the given path.
const std::filesystem::path & get_home_dir()
std::string loadTextFile(const std::filesystem::path &path, const std::filesystem::path &default_dir)
void emitSignal(Args... args)
std::vector< uint8_t > salt