8#ifndef GALAXY_FS_FILEUTILS_HPP_
9#define GALAXY_FS_FILEUTILS_HPP_
13#include <nlohmann/json_fwd.hpp>
29 std::expected<std::string, FileError>
extension(
const std::string& filepath)
noexcept;
39 std::expected<std::string, FileError>
read(
const std::string& filepath);
50 std::expected<bool, FileError>
write(
const std::string& filepath,
const std::string& data);
60 std::expected<nlohmann::json, FileError>
read_json(
const std::string& filepath);
71 std::expected<bool, FileError>
write_json(
const std::string& filepath,
const nlohmann::json& json);
78 void open_url(
const std::string& url)
noexcept;
void open_url(const std::string &url) noexcept
Open URL in default webbrowser.
std::expected< bool, FileError > write_json(const std::string &filepath, const nlohmann::json &json)
Write json to disk.
std::expected< std::string, FileError > extension(const std::string &filepath) noexcept
Get a file or path's extension.
std::expected< bool, FileError > write(const std::string &filepath, const std::string &data)
Writes a non-binary file to disk.
std::expected< std::string, FileError > read(const std::string &filepath)
Read a non-binary file on disk.
std::expected< nlohmann::json, FileError > read_json(const std::string &filepath)
Read a json file from disk.