ef73de9386
* 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. |
||
---|---|---|
.. | ||
logging | ||
x64 | ||
alignment.h | ||
announce_multiplayer_room.h | ||
assert.h | ||
bit_field.h | ||
bit_set.h | ||
chunk_file.h | ||
cityhash.cpp | ||
cityhash.h | ||
CMakeLists.txt | ||
color.h | ||
common_funcs.h | ||
common_paths.h | ||
common_types.h | ||
detached_tasks.cpp | ||
detached_tasks.h | ||
file_util.cpp | ||
file_util.h | ||
hash.h | ||
linear_disk_cache.h | ||
math_util.h | ||
microprofile.cpp | ||
microprofile.h | ||
microprofileui.h | ||
misc.cpp | ||
param_package.cpp | ||
param_package.h | ||
quaternion.h | ||
ring_buffer.h | ||
scm_rev.cpp.in | ||
scm_rev.h | ||
scope_exit.h | ||
string_util.cpp | ||
string_util.h | ||
swap.h | ||
telemetry.cpp | ||
telemetry.h | ||
thread.cpp | ||
thread.h | ||
thread_queue_list.h | ||
threadsafe_queue.h | ||
timer.cpp | ||
timer.h | ||
vector_math.h | ||
web_result.h |