2022-03-19 23:06:00 +01:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-17 00:31:15 +02:00
|
|
|
#include "updater.hpp"
|
|
|
|
|
2022-03-19 23:06:00 +01:00
|
|
|
namespace filesystem
|
|
|
|
{
|
|
|
|
std::string read_file(const std::string& path);
|
2022-04-28 22:41:29 +02:00
|
|
|
bool read_file(const std::string& path, std::string* data, std::string* real_path = nullptr);
|
2022-07-22 19:51:26 +02:00
|
|
|
bool find_file(const std::string& path, std::string* real_path);
|
2022-08-22 01:42:13 +02:00
|
|
|
bool exists(const std::string& path);
|
|
|
|
|
2022-07-15 02:02:50 +02:00
|
|
|
void register_path(const std::filesystem::path& path);
|
|
|
|
void unregister_path(const std::filesystem::path& path);
|
|
|
|
|
|
|
|
std::vector<std::string> get_search_paths();
|
2022-07-19 19:42:59 +02:00
|
|
|
std::vector<std::string> get_search_paths_rev();
|
2023-02-15 18:24:35 +01:00
|
|
|
|
|
|
|
std::string get_safe_path(const std::filesystem::path& path);
|
|
|
|
bool safe_write_file(const std::string& file, const std::string& data, bool append = false);
|
2023-02-16 19:09:44 +01:00
|
|
|
|
|
|
|
template <typename R>
|
|
|
|
std::function<R(const std::string& str)>
|
|
|
|
safe_io_func(const std::function<R(const std::string& str)>& func)
|
|
|
|
{
|
|
|
|
return [func](const std::string& path)
|
|
|
|
{
|
|
|
|
const auto safe_path = filesystem::get_safe_path(path);
|
|
|
|
return func(safe_path);
|
|
|
|
};
|
|
|
|
}
|
2022-07-19 19:42:59 +02:00
|
|
|
}
|