citra/src/common
Tobias ef73de9386
Port yuzu-emu/yuzu#2511: "common/file_util: Minor cleanup" (#4782)
* common/file_util: Make IOFile's WriteString take a std::string_view

We don't need to force the usage of a std::string here, and can instead
use a std::string_view, which allows writing out other forms of strings
(e.g. C-style strings) without any unnecessary heap allocations.

* common/file_util: Remove unnecessary c_str() calls

The file stream open functions have supported std::string overloads
since C++11, so we don't need to use c_str() here. Same behavior, less
code.

* common/file_util: Make ReadFileToString and WriteStringToFile consistent

Makes the parameter ordering consistent, and also makes the filename
parameter a std::string. A std::string would be constructed anyways with
the previous code, as IOFile's only constructor with a filepath is one
taking a std::string.

We can also make WriteStringToFile's string parameter utilize a
std::string_view for the string, making use of our previous changes to
IOFile.

* common/file_util: Remove duplicated documentation comments

These are already present within the header, so they don't need to be
repeated in the cpp file.

* common/file_util: Make GetCurrentDir() return a std::optional

nullptr was being returned in the error case, which, at a glance may
seem perfectly OK... until you realize that std::string has the
invariant that it may not be constructed from a null pointer. This
means that if this error case was ever hit, then the application would
most likely crash from a thrown exception in std::string's constructor.

Instead, we can change the function to return an optional value,
indicating if a failure occurred.

* common/file_util: Remove unnecessary return at end of void StripTailDirSlashes()

While we're at it, also invert the conditional into a guard clause.
2019-06-08 00:23:57 +02:00
..
logging Merge pull request #4733 from zhaowenlan1779/ps 2019-04-29 21:39:53 +08:00
x64 Prefix all size_t with std:: 2018-09-06 16:03:28 -04:00
alignment.h Prefix all size_t with std:: 2018-09-06 16:03:28 -04:00
announce_multiplayer_room.h core, web_service: Check for error when registering rooms 2019-04-20 12:50:14 +08:00
assert.h reformat all files with clang-format 2018-06-29 16:56:12 +03:00
bit_field.h common/bit_field: Make BitField trivially copyable 2019-03-16 04:10:03 +01:00
bit_set.h Prefix all size_t with std:: 2018-09-06 16:03:28 -04:00
chunk_file.h reformat all files with clang-format 2018-06-29 16:56:12 +03:00
cityhash.cpp Prefix all size_t with std:: 2018-09-06 16:03:28 -04:00
cityhash.h Prefix all size_t with std:: 2018-09-06 16:03:28 -04:00
CMakeLists.txt common/thread_queue_list: Remove unnecessary dependency on boost 2019-03-22 23:13:30 +01:00
color.h common/vector_math: Move Vec[x] types into the Common namespace 2019-03-02 15:04:13 +01:00
common_funcs.h Merge pull request #4021 from FearlessTobi/port-709 2018-08-02 11:00:53 -06:00
common_paths.h FFmpegDL: Added external_dlls folder to user folder 2019-02-09 11:52:31 +01:00
common_types.h Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
detached_tasks.cpp general: Use deducation guides for std::lock_guard and std::unique_lock 2019-04-07 15:14:29 +02:00
detached_tasks.h Review comments - part 5 2018-10-20 10:35:55 -04:00
file_util.cpp Port yuzu-emu/yuzu#2511: "common/file_util: Minor cleanup" (#4782) 2019-06-08 00:23:57 +02:00
file_util.h Port yuzu-emu/yuzu#2511: "common/file_util: Minor cleanup" (#4782) 2019-06-08 00:23:57 +02:00
hash.h Prefix all size_t with std:: 2018-09-06 16:03:28 -04:00
linear_disk_cache.h Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
math_util.h common/math_util: Provide a template deduction guide for Common::Rectangle 2019-06-01 02:10:36 +02:00
microprofile.cpp Integrate the MicroProfile profiling library 2015-08-24 22:16:28 -03:00
microprofile.h Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
microprofileui.h Common: Remove section measurement from profiler (#1731) 2016-04-29 00:07:10 -07:00
misc.cpp Prefix all size_t with std:: 2018-09-06 16:03:28 -04:00
param_package.cpp citra_qt/configuration: misc input tab improvements 2018-09-08 11:26:10 +08:00
param_package.h citra_qt/configuration: misc input tab improvements 2018-09-08 11:26:10 +08:00
quaternion.h common/vector_math: Move Vec[x] types into the Common namespace 2019-03-02 15:04:13 +01:00
ring_buffer.h ring_buffer: Fix Push 2018-09-19 07:14:36 +01:00
scm_rev.cpp.in common: Parse Nightly/Canary build version 2018-06-20 09:30:26 +08:00
scm_rev.h common: Parse Nightly/Canary build version 2018-06-20 09:30:26 +08:00
scope_exit.h common/scope_exit: Replace std::move with std::forward in ScopeExit() 2019-04-15 17:55:44 +02:00
string_util.cpp remove Common::TrimSourcePath 2019-03-10 19:18:09 -05:00
string_util.h common/string_util: Move TextFromBuffer to string_util 2019-04-08 22:34:21 +08:00
swap.h common/swap: Improve codegen of the default swap fallbacks 2019-04-15 17:56:16 +02:00
telemetry.cpp common: Add a generic interface for logging telemetry fields. 2017-05-24 19:16:21 -04:00
telemetry.h compatdb: Use a seperate endpoint for testcase submission 2018-10-27 12:20:03 +02:00
thread.cpp Port various minor changes from yuzu PRs (#4725) 2019-05-01 14:28:49 +02:00
thread.h Port various minor changes from yuzu PRs (#4725) 2019-05-01 14:28:49 +02:00
thread_queue_list.h common/thread_queue_list: Remove unnecessary dependency on boost 2019-03-22 23:13:30 +01:00
threadsafe_queue.h general: Use deducation guides for std::lock_guard and std::unique_lock 2019-04-07 15:14:29 +02:00
timer.cpp Address review comments 2018-09-06 00:00:21 +02:00
timer.h common/timer: use std::chrono, avoid platform-dependent code 2018-07-22 15:40:07 +08:00
vector_math.h common/vector_math: Move Vec[x] types into the Common namespace 2019-03-02 15:04:13 +01:00
web_result.h Put WebResult into a seperate file 2018-10-27 00:39:02 +02:00