summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/string_util.cpp4
-rw-r--r--src/common/string_util.h2
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp31
3 files changed, 15 insertions, 22 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 1d952874d..646400db0 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -64,6 +64,10 @@ std::string ArrayToString(const u8* data, size_t size, int line_len, bool spaces
64 return oss.str(); 64 return oss.str();
65} 65}
66 66
67std::string StringFromBuffer(const std::vector<u8>& data) {
68 return std::string(data.begin(), std::find(data.begin(), data.end(), '\0'));
69}
70
67// Turns " hej " into "hej". Also handles tabs. 71// Turns " hej " into "hej". Also handles tabs.
68std::string StripSpaces(const std::string& str) { 72std::string StripSpaces(const std::string& str) {
69 const size_t s = str.find_first_not_of(" \t\r\n"); 73 const size_t s = str.find_first_not_of(" \t\r\n");
diff --git a/src/common/string_util.h b/src/common/string_util.h
index 65e4ea5d3..1f5a383cb 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -21,6 +21,8 @@ std::string ToUpper(std::string str);
21 21
22std::string ArrayToString(const u8* data, size_t size, int line_len = 20, bool spaces = true); 22std::string ArrayToString(const u8* data, size_t size, int line_len = 20, bool spaces = true);
23 23
24std::string StringFromBuffer(const std::vector<u8>& data);
25
24std::string StripSpaces(const std::string& s); 26std::string StripSpaces(const std::string& s);
25std::string StripQuotes(const std::string& s); 27std::string StripQuotes(const std::string& s);
26 28
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 8a47bb7af..1cf97e876 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -4,6 +4,7 @@
4 4
5#include <cinttypes> 5#include <cinttypes>
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "common/string_util.h"
7#include "core/core.h" 8#include "core/core.h"
8#include "core/file_sys/directory.h" 9#include "core/file_sys/directory.h"
9#include "core/file_sys/filesystem.h" 10#include "core/file_sys/filesystem.h"
@@ -258,9 +259,7 @@ public:
258 IPC::RequestParser rp{ctx}; 259 IPC::RequestParser rp{ctx};
259 260
260 auto file_buffer = ctx.ReadBuffer(); 261 auto file_buffer = ctx.ReadBuffer();
261 auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0'); 262 std::string name = Common::StringFromBuffer(file_buffer);
262
263 std::string name(file_buffer.begin(), end);
264 263
265 u64 mode = rp.Pop<u64>(); 264 u64 mode = rp.Pop<u64>();
266 u32 size = rp.Pop<u32>(); 265 u32 size = rp.Pop<u32>();
@@ -275,9 +274,7 @@ public:
275 IPC::RequestParser rp{ctx}; 274 IPC::RequestParser rp{ctx};
276 275
277 auto file_buffer = ctx.ReadBuffer(); 276 auto file_buffer = ctx.ReadBuffer();
278 auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0'); 277 std::string name = Common::StringFromBuffer(file_buffer);
279
280 std::string name(file_buffer.begin(), end);
281 278
282 NGLOG_DEBUG(Service_FS, "called file {}", name); 279 NGLOG_DEBUG(Service_FS, "called file {}", name);
283 280
@@ -289,9 +286,7 @@ public:
289 IPC::RequestParser rp{ctx}; 286 IPC::RequestParser rp{ctx};
290 287
291 auto file_buffer = ctx.ReadBuffer(); 288 auto file_buffer = ctx.ReadBuffer();
292 auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0'); 289 std::string name = Common::StringFromBuffer(file_buffer);
293
294 std::string name(file_buffer.begin(), end);
295 290
296 NGLOG_DEBUG(Service_FS, "called directory {}", name); 291 NGLOG_DEBUG(Service_FS, "called directory {}", name);
297 292
@@ -305,13 +300,11 @@ public:
305 std::vector<u8> buffer; 300 std::vector<u8> buffer;
306 buffer.resize(ctx.BufferDescriptorX()[0].Size()); 301 buffer.resize(ctx.BufferDescriptorX()[0].Size());
307 Memory::ReadBlock(ctx.BufferDescriptorX()[0].Address(), buffer.data(), buffer.size()); 302 Memory::ReadBlock(ctx.BufferDescriptorX()[0].Address(), buffer.data(), buffer.size());
308 auto end = std::find(buffer.begin(), buffer.end(), '\0'); 303 std::string src_name = Common::StringFromBuffer(buffer);
309 std::string src_name(buffer.begin(), end);
310 304
311 buffer.resize(ctx.BufferDescriptorX()[1].Size()); 305 buffer.resize(ctx.BufferDescriptorX()[1].Size());
312 Memory::ReadBlock(ctx.BufferDescriptorX()[1].Address(), buffer.data(), buffer.size()); 306 Memory::ReadBlock(ctx.BufferDescriptorX()[1].Address(), buffer.data(), buffer.size());
313 end = std::find(buffer.begin(), buffer.end(), '\0'); 307 std::string dst_name = Common::StringFromBuffer(buffer);
314 std::string dst_name(buffer.begin(), end);
315 308
316 NGLOG_DEBUG(Service_FS, "called file '{}' to file '{}'", src_name, dst_name); 309 NGLOG_DEBUG(Service_FS, "called file '{}' to file '{}'", src_name, dst_name);
317 310
@@ -323,9 +316,7 @@ public:
323 IPC::RequestParser rp{ctx}; 316 IPC::RequestParser rp{ctx};
324 317
325 auto file_buffer = ctx.ReadBuffer(); 318 auto file_buffer = ctx.ReadBuffer();
326 auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0'); 319 std::string name = Common::StringFromBuffer(file_buffer);
327
328 std::string name(file_buffer.begin(), end);
329 320
330 auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>()); 321 auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>());
331 322
@@ -349,9 +340,7 @@ public:
349 IPC::RequestParser rp{ctx}; 340 IPC::RequestParser rp{ctx};
350 341
351 auto file_buffer = ctx.ReadBuffer(); 342 auto file_buffer = ctx.ReadBuffer();
352 auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0'); 343 std::string name = Common::StringFromBuffer(file_buffer);
353
354 std::string name(file_buffer.begin(), end);
355 344
356 // TODO(Subv): Implement this filter. 345 // TODO(Subv): Implement this filter.
357 u32 filter_flags = rp.Pop<u32>(); 346 u32 filter_flags = rp.Pop<u32>();
@@ -376,9 +365,7 @@ public:
376 IPC::RequestParser rp{ctx}; 365 IPC::RequestParser rp{ctx};
377 366
378 auto file_buffer = ctx.ReadBuffer(); 367 auto file_buffer = ctx.ReadBuffer();
379 auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0'); 368 std::string name = Common::StringFromBuffer(file_buffer);
380
381 std::string name(file_buffer.begin(), end);
382 369
383 NGLOG_DEBUG(Service_FS, "called file {}", name); 370 NGLOG_DEBUG(Service_FS, "called file {}", name);
384 371