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
..
2018-09-06 16:03:28 -04:00
2018-09-06 16:03:28 -04:00
2018-06-29 16:56:12 +03:00
2018-09-06 16:03:28 -04:00
2018-09-06 16:03:28 -04:00
2018-09-06 16:03:28 -04:00
2018-10-20 10:35:55 -04:00
2018-09-06 16:03:28 -04:00
2018-09-06 16:03:28 -04:00
2018-09-19 07:14:36 +01:00
2019-03-10 19:18:09 -05:00
2018-09-06 00:00:21 +02:00