summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar bunnei2018-06-08 18:51:00 -0400
committerGravatar GitHub2018-06-08 18:51:00 -0400
commit9949e4d508ed686cd6b66461868c3a16445fa225 (patch)
tree390ca18637ba51f2f5709a2bd01fb6ef55b6fdcc /src/core
parentMerge pull request #548 from Subv/blend (diff)
parentCommon/string_util: add StringFromBuffer function (diff)
downloadyuzu-9949e4d508ed686cd6b66461868c3a16445fa225.tar.gz
yuzu-9949e4d508ed686cd6b66461868c3a16445fa225.tar.xz
yuzu-9949e4d508ed686cd6b66461868c3a16445fa225.zip
Merge pull request #533 from mailwl/array-to-buffer
Common/string_util: add StringFromBuffer() function
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp31
1 files changed, 9 insertions, 22 deletions
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