mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Merge pull request #12376 from lioncash/span2
VFFUtil: Use std::span with WriteToVFF
This commit is contained in:
commit
99959944eb
@ -219,13 +219,13 @@ ErrorCode WC24SendList::AddRegistrationMessages(const WC24FriendList& friend_lis
|
|||||||
const u32 msg_id = GetNextEntryId();
|
const u32 msg_id = GetNextEntryId();
|
||||||
m_data.entries[entry_index].id = Common::swap32(msg_id);
|
m_data.entries[entry_index].id = Common::swap32(msg_id);
|
||||||
|
|
||||||
std::time_t t = std::time(nullptr);
|
const std::time_t t = std::time(nullptr);
|
||||||
|
|
||||||
const std::string formatted_message =
|
const std::string formatted_message =
|
||||||
fmt::format(MAIL_REGISTRATION_STRING, sender, code, fmt::gmtime(t));
|
fmt::format(MAIL_REGISTRATION_STRING, sender, code, fmt::gmtime(t));
|
||||||
std::vector<u8> message{formatted_message.begin(), formatted_message.end()};
|
const std::span message{reinterpret_cast<const u8*>(formatted_message.data()),
|
||||||
NWC24::ErrorCode reply =
|
formatted_message.size()};
|
||||||
NWC24::WriteToVFF(NWC24::Mail::SEND_BOX_PATH, GetMailPath(entry_index), m_fs, message);
|
const ErrorCode reply = WriteToVFF(SEND_BOX_PATH, GetMailPath(entry_index), m_fs, message);
|
||||||
|
|
||||||
if (reply != WC24_OK)
|
if (reply != WC24_OK)
|
||||||
{
|
{
|
||||||
|
@ -189,7 +189,7 @@ static DRESULT vff_ioctl(IOS::HLE::FS::FileHandle* vff, BYTE pdrv, BYTE cmd, voi
|
|||||||
|
|
||||||
namespace IOS::HLE::NWC24
|
namespace IOS::HLE::NWC24
|
||||||
{
|
{
|
||||||
static ErrorCode WriteFile(const std::string& filename, const std::vector<u8>& tmp_buffer)
|
static ErrorCode WriteFile(const std::string& filename, std::span<const u8> tmp_buffer)
|
||||||
{
|
{
|
||||||
FIL dst{};
|
FIL dst{};
|
||||||
const auto open_error_code = f_open(&dst, filename.c_str(), FA_CREATE_ALWAYS | FA_WRITE);
|
const auto open_error_code = f_open(&dst, filename.c_str(), FA_CREATE_ALWAYS | FA_WRITE);
|
||||||
@ -301,7 +301,7 @@ public:
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ErrorCode WriteToVFF(const std::string& path, const std::string& filename,
|
ErrorCode WriteToVFF(const std::string& path, const std::string& filename,
|
||||||
const std::shared_ptr<FS::FileSystem>& fs, const std::vector<u8>& data)
|
const std::shared_ptr<FS::FileSystem>& fs, std::span<const u8> data)
|
||||||
{
|
{
|
||||||
VffFatFsCallbacks callbacks;
|
VffFatFsCallbacks callbacks;
|
||||||
ErrorCode return_value;
|
ErrorCode return_value;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ constexpr u16 SECTOR_SIZE = 512;
|
|||||||
constexpr u16 VF_LITTLE_ENDIAN = 0xFFFE;
|
constexpr u16 VF_LITTLE_ENDIAN = 0xFFFE;
|
||||||
constexpr u16 VF_BIG_ENDIAN = 0xFEFF;
|
constexpr u16 VF_BIG_ENDIAN = 0xFEFF;
|
||||||
ErrorCode WriteToVFF(const std::string& path, const std::string& filename,
|
ErrorCode WriteToVFF(const std::string& path, const std::string& filename,
|
||||||
const std::shared_ptr<FS::FileSystem>& fs, const std::vector<u8>& data);
|
const std::shared_ptr<FS::FileSystem>& fs, std::span<const u8> data);
|
||||||
ErrorCode ReadFromVFF(const std::string& path, const std::string& filename,
|
ErrorCode ReadFromVFF(const std::string& path, const std::string& filename,
|
||||||
const std::shared_ptr<FS::FileSystem>& fs, std::vector<u8>& out);
|
const std::shared_ptr<FS::FileSystem>& fs, std::vector<u8>& out);
|
||||||
ErrorCode DeleteFileFromVFF(const std::string& path, const std::string& filename,
|
ErrorCode DeleteFileFromVFF(const std::string& path, const std::string& filename,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user