mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 19:23:56 +00:00
Support std::byte in I/O util
This commit is contained in:
@@ -21,7 +21,7 @@ namespace utils::io
|
||||
return std::ifstream(file).good();
|
||||
}
|
||||
|
||||
bool write_file(const std::filesystem::path& file, const std::vector<uint8_t>& data, const bool append)
|
||||
bool write_file(const std::filesystem::path& file, const std::span<const uint8_t> data, const bool append)
|
||||
{
|
||||
if (file.has_parent_path())
|
||||
{
|
||||
@@ -41,6 +41,11 @@ namespace utils::io
|
||||
return false;
|
||||
}
|
||||
|
||||
bool write_file(const std::filesystem::path& file, const std::span<const std::byte> data, const bool append)
|
||||
{
|
||||
return write_file(file, std::span(reinterpret_cast<const uint8_t*>(data.data()), data.size()), append);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> read_file(const std::filesystem::path& file)
|
||||
{
|
||||
std::vector<uint8_t> data;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace utils::io
|
||||
bool remove_file(const std::filesystem::path& file);
|
||||
bool move_file(const std::filesystem::path& src, const std::filesystem::path& target);
|
||||
bool file_exists(const std::filesystem::path& file);
|
||||
bool write_file(const std::filesystem::path& file, const std::vector<uint8_t>& data, bool append = false);
|
||||
bool write_file(const std::filesystem::path& file, std::span<const uint8_t> data, bool append = false);
|
||||
bool write_file(const std::filesystem::path& file, std::span<const std::byte> data, bool append = false);
|
||||
bool read_file(const std::filesystem::path& file, std::vector<uint8_t>* data);
|
||||
std::vector<uint8_t> read_file(const std::filesystem::path& file);
|
||||
size_t file_size(const std::filesystem::path& file);
|
||||
|
||||
Reference in New Issue
Block a user