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#include <optional>
13
14#include <nlohmann/json_fwd.hpp>
15
17
18namespace galaxy
19{
20 namespace fileutils
21 {
29 [[nodiscard]]
30 std::optional<std::string> extension(const std::string& filepath) noexcept;
31
39 [[nodiscard]]
40 std::expected<std::string, FileError> read(const std::string& filepath);
41
50 [[nodiscard]]
51 std::optional<FileError> write(const std::string& filepath, const std::string& data);
52
60 [[nodiscard]]
61 std::optional<nlohmann::json> read_json(const std::string& filepath);
62
71 [[nodiscard]]
72 bool write_json(const std::string& filepath, const nlohmann::json& json);
73
79 void open_url(const std::string& url) noexcept;
80 } // namespace fileutils
81} // namespace galaxy
82
83#endif
std::optional< FileError > write(const std::string &filepath, const std::string &data)
Writes a non-binary file to disk.
Definition FileUtils.cpp:62
void open_url(const std::string &url) noexcept
Open URL in default webbrowser.
std::optional< std::string > extension(const std::string &filepath) noexcept
Get a file or path's extension.
Definition FileUtils.cpp:21
bool write_json(const std::string &filepath, const nlohmann::json &json)
Write json to disk.
std::expected< std::string, FileError > read(const std::string &filepath)
Read a non-binary file on disk.
Definition FileUtils.cpp:32
std::optional< nlohmann::json > read_json(const std::string &filepath)
Read a json file from disk.
Definition FileUtils.cpp:89
Animated.cpp galaxy.
Definition Animated.cpp:16