galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
FileUtils.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_FS_FILEUTILS_HPP_
9#define GALAXY_FS_FILEUTILS_HPP_
10
11#include <expected>
12
13#include <nlohmann/json_fwd.hpp>
14
16
17namespace galaxy
18{
19 namespace fileutils
20 {
28 [[nodiscard]]
29 std::expected<std::string, FileError> extension(const std::string& filepath) noexcept;
30
38 [[nodiscard]]
39 std::expected<std::string, FileError> read(const std::string& filepath);
40
49 [[nodiscard]]
50 std::expected<bool, FileError> write(const std::string& filepath, const std::string& data);
51
59 [[nodiscard]]
60 std::expected<nlohmann::json, FileError> read_json(const std::string& filepath);
61
70 [[nodiscard]]
71 std::expected<bool, FileError> write_json(const std::string& filepath, const nlohmann::json& json);
72
78 void open_url(const std::string& url) noexcept;
79 } // namespace fileutils
80} // namespace galaxy
81
82#endif
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.
Definition FileUtils.cpp:21
std::expected< bool, FileError > write(const std::string &filepath, const std::string &data)
Writes a non-binary file to disk.
Definition FileUtils.cpp:62
std::expected< std::string, FileError > read(const std::string &filepath)
Read a non-binary file on disk.
Definition FileUtils.cpp:32
std::expected< nlohmann::json, FileError > read_json(const std::string &filepath)
Read a json file from disk.
Definition FileUtils.cpp:89
Application.hpp galaxy.