mirror of https://git.suyu.dev/suyu/suyu
fsp_srv: Use ReadBufferSpan
This commit is contained in:
parent
9349f06963
commit
fbc375f0de
|
@ -30,7 +30,7 @@ std::string ToUpper(std::string str) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StringFromBuffer(const std::vector<u8>& data) {
|
std::string StringFromBuffer(std::span<const u8> data) {
|
||||||
return std::string(data.begin(), std::find(data.begin(), data.end(), '\0'));
|
return std::string(data.begin(), std::find(data.begin(), data.end(), '\0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
@ -17,7 +18,7 @@ namespace Common {
|
||||||
/// Make a string uppercase
|
/// Make a string uppercase
|
||||||
[[nodiscard]] std::string ToUpper(std::string str);
|
[[nodiscard]] std::string ToUpper(std::string str);
|
||||||
|
|
||||||
[[nodiscard]] std::string StringFromBuffer(const std::vector<u8>& data);
|
[[nodiscard]] std::string StringFromBuffer(std::span<const u8> data);
|
||||||
|
|
||||||
[[nodiscard]] std::string StripSpaces(const std::string& s);
|
[[nodiscard]] std::string StripSpaces(const std::string& s);
|
||||||
[[nodiscard]] std::string StripQuotes(const std::string& s);
|
[[nodiscard]] std::string StripQuotes(const std::string& s);
|
||||||
|
|
|
@ -190,7 +190,7 @@ private:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<u8> data = ctx.ReadBuffer();
|
const auto data = ctx.ReadBufferSpan();
|
||||||
|
|
||||||
ASSERT_MSG(
|
ASSERT_MSG(
|
||||||
static_cast<s64>(data.size()) <= length,
|
static_cast<s64>(data.size()) <= length,
|
||||||
|
@ -337,7 +337,7 @@ public:
|
||||||
void CreateFile(Kernel::HLERequestContext& ctx) {
|
void CreateFile(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
const u64 file_mode = rp.Pop<u64>();
|
const u64 file_mode = rp.Pop<u64>();
|
||||||
|
@ -351,7 +351,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteFile(Kernel::HLERequestContext& ctx) {
|
void DeleteFile(Kernel::HLERequestContext& ctx) {
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. file={}", name);
|
LOG_DEBUG(Service_FS, "called. file={}", name);
|
||||||
|
@ -361,7 +361,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateDirectory(Kernel::HLERequestContext& ctx) {
|
void CreateDirectory(Kernel::HLERequestContext& ctx) {
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. directory={}", name);
|
LOG_DEBUG(Service_FS, "called. directory={}", name);
|
||||||
|
@ -371,7 +371,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteDirectory(Kernel::HLERequestContext& ctx) {
|
void DeleteDirectory(Kernel::HLERequestContext& ctx) {
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. directory={}", name);
|
LOG_DEBUG(Service_FS, "called. directory={}", name);
|
||||||
|
@ -381,7 +381,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteDirectoryRecursively(Kernel::HLERequestContext& ctx) {
|
void DeleteDirectoryRecursively(Kernel::HLERequestContext& ctx) {
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. directory={}", name);
|
LOG_DEBUG(Service_FS, "called. directory={}", name);
|
||||||
|
@ -391,7 +391,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanDirectoryRecursively(Kernel::HLERequestContext& ctx) {
|
void CleanDirectoryRecursively(Kernel::HLERequestContext& ctx) {
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. Directory: {}", name);
|
LOG_DEBUG(Service_FS, "called. Directory: {}", name);
|
||||||
|
@ -401,11 +401,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenameFile(Kernel::HLERequestContext& ctx) {
|
void RenameFile(Kernel::HLERequestContext& ctx) {
|
||||||
std::vector<u8> buffer = ctx.ReadBuffer(0);
|
const std::string src_name = Common::StringFromBuffer(ctx.ReadBufferSpan(0));
|
||||||
const std::string src_name = Common::StringFromBuffer(buffer);
|
const std::string dst_name = Common::StringFromBuffer(ctx.ReadBufferSpan(1));
|
||||||
|
|
||||||
buffer = ctx.ReadBuffer(1);
|
|
||||||
const std::string dst_name = Common::StringFromBuffer(buffer);
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name);
|
LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name);
|
||||||
|
|
||||||
|
@ -416,7 +413,7 @@ public:
|
||||||
void OpenFile(Kernel::HLERequestContext& ctx) {
|
void OpenFile(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
const auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>());
|
const auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>());
|
||||||
|
@ -440,7 +437,7 @@ public:
|
||||||
void OpenDirectory(Kernel::HLERequestContext& ctx) {
|
void OpenDirectory(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
// TODO(Subv): Implement this filter.
|
// TODO(Subv): Implement this filter.
|
||||||
|
@ -463,7 +460,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetEntryType(Kernel::HLERequestContext& ctx) {
|
void GetEntryType(Kernel::HLERequestContext& ctx) {
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
LOG_DEBUG(Service_FS, "called. file={}", name);
|
LOG_DEBUG(Service_FS, "called. file={}", name);
|
||||||
|
@ -504,7 +501,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetFileTimeStampRaw(Kernel::HLERequestContext& ctx) {
|
void GetFileTimeStampRaw(Kernel::HLERequestContext& ctx) {
|
||||||
const auto file_buffer = ctx.ReadBuffer();
|
const auto file_buffer = ctx.ReadBufferSpan();
|
||||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||||
|
|
||||||
LOG_WARNING(Service_FS, "(Partial Implementation) called. file={}", name);
|
LOG_WARNING(Service_FS, "(Partial Implementation) called. file={}", name);
|
||||||
|
@ -1086,7 +1083,7 @@ void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) {
|
void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) {
|
||||||
const auto raw = ctx.ReadBuffer();
|
const auto raw = ctx.ReadBufferSpan();
|
||||||
auto log = Common::StringFromFixedZeroTerminatedBuffer(
|
auto log = Common::StringFromFixedZeroTerminatedBuffer(
|
||||||
reinterpret_cast<const char*>(raw.data()), raw.size());
|
reinterpret_cast<const char*>(raw.data()), raw.size());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue