2022-03-19 18:06:00 -04:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-16 18:31:15 -04:00
|
|
|
#include "updater.hpp"
|
|
|
|
|
2022-03-19 18:06:00 -04:00
|
|
|
namespace filesystem
|
|
|
|
{
|
|
|
|
std::string read_file(const std::string& path);
|
2022-04-28 16:41:29 -04:00
|
|
|
bool read_file(const std::string& path, std::string* data, std::string* real_path = nullptr);
|
2022-07-22 13:51:26 -04:00
|
|
|
bool find_file(const std::string& path, std::string* real_path);
|
2022-08-21 19:42:13 -04:00
|
|
|
bool exists(const std::string& path);
|
|
|
|
|
2022-07-14 20:02:50 -04: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 13:42:59 -04:00
|
|
|
std::vector<std::string> get_search_paths_rev();
|
2023-02-15 12:24:35 -05: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 13:09:44 -05: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 13:42:59 -04:00
|
|
|
}
|