Files
Morgan Pretty 789828fd97 Fixed up a few issues
• Added a missing import
• Updated the OnionRequestRouter to wait for the SnodePool to be populated before allowing any requests to be sent
• Updated the SnodePool to make ephemeral connections to refresh it's cache (that way we won't always use seed node connections for subsequent requests on new accounts)
• Fixed some use-after-move issues
• Fixed an issue were the SnodePool bootstrap request response wasn't being handled
2025-08-01 16:31:29 +10:00

30 lines
1.0 KiB
C++

#pragma once
#include <filesystem>
#include <iosfwd>
#include <string>
#include <string_view>
#include <vector>
// Utility functions for working with files
namespace session {
namespace fs = std::filesystem;
/// Opens a file for writing of binary data, setting up the returned ofstream with exceptions
/// enabled for any failures. This also throws if the file cannot be opened. If the file already
/// exists it will be truncated.
std::ofstream open_for_writing(const fs::path& filename);
/// Opens a file for reading of binary data, setting up the returned ifstream with exceptions
/// enabled for any failures. This also throws if the file cannot be opened.
std::ifstream open_for_reading(const fs::path& filename);
/// Reads a (binary) file from disk.
std::vector<std::byte> read_whole_file(const fs::path& filename);
/// Dumps (binary) string contents to disk. The file is overwritten if it already exists.
void write_whole_file(const fs::path& filename, std::string_view contents = "");
} // namespace session