Commit Graph

80 Commits (2e74b79e89fe1e6a21fe0d8650844e563b3c32f5)

Author SHA1 Message Date
bunnei 3d592972dc
Revert "core: Fix clang build" 5 years ago
Lioncash be1954e04c core: Fix clang build
Recent changes to the build system that made more warnings be flagged as
errors caused building via clang to break.

Fixes #4795
5 years ago
Lioncash c4ed791164 common/fileutil: Convert namespace to Common::FS
Migrates a remaining common file over to the Common namespace, making it
consistent with the rest of common files.

This also allows for high-traffic FS related code to alias the
filesystem function namespace as

namespace FS = Common::FS;

for more concise typing.
5 years ago
Lioncash df72480395 common: Make use of [[nodiscard]] where applicable
Now that clang-format makes [[nodiscard]] attributes format sensibly, we
can apply them to several functions within the common library to allow
the compiler to complain about any misuses of the functions.
5 years ago
lat9nq 3848155c42 common: Add a screenshots directory
Adds a screenshots directory as a path managed by FileUtil.
5 years ago
Lioncash e77337588e file_util: Early-exit in WriteArray and ReadArray if specified lengths are zero
It's undefined behavior to pass a null pointer to std::fread and
std::fwrite, even if the length passed in is zero, so we must perform
the precondition checking ourselves.

A common case where this can occur is when passing in the data of an
empty std::vector and size, as an empty vector will typically have a
null internal buffer.

While we're at it, we can move the implementation out of line and add
debug checks against passing in nullptr to std::fread and std::fwrite.
5 years ago
Lioncash 11e9bee91d 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.
6 years ago
Lioncash 2b1fcc8a14 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.
6 years ago
Lioncash e3b2539986 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.
6 years ago
Lioncash 8cd3d9be26 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.
6 years ago
ReinUsesLisp 84412591c9 file_util: Add shader directory 6 years ago
Weiyi Wang bfe84f06f2 string_util: remove TString conversion for windows
First of all they are foundamentally broken. As our convention is that std::string is always UTF-8, these functions assume that the multi-byte character version of TString (std::string) from windows is also in UTF-8, which is almost always wrong. We are not going to build multi-byte character build, and even if we do, this dirty work should be handled by frontend framework early.
7 years ago
Zach Hilman bd8db3f7f8 common_paths: Add Load and Dump dirs 7 years ago
fearlessTobi 63c2e32e20 Port #4182 from Citra: "Prefix all size_t with std::" 7 years ago
Zach Hilman b70a831608 file_util: Add getter for NAND registration directory 7 years ago
Zach Hilman 2b6128fe0b file_util: Use enum instead of bool for specifing path behavior 7 years ago
Zach Hilman 3f82dad1e4 file_util: Add platform-specific slash option to SanitizePath 7 years ago
bunnei d224eb7c39
Merge pull request #966 from lioncash/modernize
common: Convert type traits templates over to variable template versions where applicable
7 years ago
Lioncash a7d6efc520 common: Convert type traits templates over to variable template versions where applicable
Uses the C++17 inline variable variants
7 years ago
Lioncash 0735a0c8a1 file_util: Avoid sign-conversions in WriteArray() and ReadArray()
Prevents compiler warnings.
7 years ago
Zach Hilman 150527ec19 Allow key loading from %YUZU_DIR%/keys in addition to ~/.switch 7 years ago
Zach Hilman df5b75694f Remove files that are not used 7 years ago
Zach Hilman 59cb258409 VFS Regression and Accuracy Fixes (#776)
* Regression and Mode Fixes

* Review Fixes

* string_view correction

* Add operator& for FileSys::Mode

* Return std::string from SanitizePath

* Farming Simulator Fix

* Use != With mode operator&
7 years ago
Lioncash 398444e676 file_util, vfs: Use std::string_view where applicable
Avoids unnecessary construction of std::string instances where
applicable.
7 years ago
Lioncash 0ba7fe4ab1 file_util: Use a u64 to represent number of entries
This avoids a truncating cast on size. I doubt we'd ever traverse a
directory this large, however we also shouldn't truncate sizes away.
7 years ago
Lioncash d66b43dadf file_util: Use an enum class for GetUserPath()
Instead of using an unsigned int as a parameter and expecting a user to
always pass in the correct values, we can just convert the enum into an
enum class and use that type as the parameter type instead, which makes
the interface more type safe.

We also get rid of the bookkeeping "NUM_" element in the enum by just
using an unordered map. This function is generally low-frequency in
terms of calls (and I'd hope so, considering otherwise would mean we're
slamming the disk with IO all the time) so I'd consider this acceptable
in this case.
7 years ago
Lioncash 63e64f0131 file_util: return string by const reference for GetExeDirectory()
This disallows modifying the internal string buffer (which shouldn't be
modified anyhow).
7 years ago
Zach Hilman 29aff8d5ab Virtual Filesystem 2: Electric Boogaloo (#676)
* Virtual Filesystem

* Fix delete bug and documentate

* Review fixes + other stuff

* Fix puyo regression
7 years ago
bunnei 913896cbd9 Revert "Virtual Filesystem (#597)"
This reverts commit 77c684c114.
7 years ago
Zach Hilman 77c684c114 Virtual Filesystem (#597)
* Add VfsFile and VfsDirectory classes

* Finish abstract Vfs classes

* Implement RealVfsFile (computer fs backend)

* Finish RealVfsFile and RealVfsDirectory

* Finished OffsetVfsFile

* More changes

* Fix import paths

* Major refactor

* Remove double const

* Use experimental/filesystem or filesystem depending on compiler

* Port partition_filesystem

* More changes

* More Overhaul

* FSP_SRV fixes

* Fixes and testing

* Try to get filesystem to compile

* Filesystem on linux

* Remove std::filesystem and document/test

* Compile fixes

* Missing include

* Bug fixes

* Fixes

* Rename v_file and v_dir

* clang-format fix

* Rename NGLOG_* to LOG_*

* Most review changes

* Fix TODO

* Guess 'main' to be Directory by filename
7 years ago
James Rowe 6269a01b4e Add configurable logging backends 7 years ago
Lioncash e8bbafb746
file_util: Make move constructor/assignment operator and related functions noexcept
Without this, it's possible to get compilation failures in the (rare) scenario where
a container is used to store a bunch of live IOFile instances, as they may be using
std::move_if_noexcept under the hood. Given these definitely don't throw exceptions
this is also not incorrect to add either.
7 years ago
Lioncash 40d2dcabd7
file_util: Add static assertions to ReadBytes() and WriteBytes()
Ensure that the actual types being passed in are trivially copyable. The internal
call to ReadArray() and WriteArray() will always succeed, since they're passed a pointer to char*
which is always trivially copyable.
7 years ago
Lioncash 5d9ee12b1a
file_util: Remove compiler version checks around is_trivially_copyable()
The minimum clang/GCC versions we support already support this. We can also
remove is_standard_layout(), as fread and fwrite only require the type to be
trivially copyable.
7 years ago
N00byKing 75da830c13
file_util.h: Update Comment from citra to yuzu 7 years ago
James Rowe 096be16636 Format: Run the new clang format on everything 7 years ago
bunnei 707cc66362 file_util: Remove unused paths. 8 years ago
freiro 79317b63d9 Switch to AppData/Roaming 9 years ago
freiro 3d75e3cd07 Return by value and other fixes 9 years ago
freiro 29bb82cb8e Win32 move default user folder location to AppData 9 years ago
Emmanuel Gil Peyrot ebdae19fd2 Remove empty newlines in #include blocks.
This makes clang-format useful on those.

Also add a bunch of forgotten transitive includes, which otherwise
prevented compilation.
9 years ago
Emmanuel Gil Peyrot dc8479928c Sources: Run clang-format on everything. 9 years ago
Yuri Kunde Schlesner d6792632f0 Fix recursive scanning of directories
ForeachDirectoryEntry didn't actually do anything with the `recursive`
parameter, and the corresponding callback parameter was shadowing the
actual recursion counters in the user functions.
9 years ago
Emmanuel Gil Peyrot 8ab6f26c09 Common: Make recursive FileUtil functions take a maximum recursion
Fixes #1115.

Also improves the performances of DiskArchive’s directory
implementation a lot, simply by not going through the entire tree
instead of just listing the first level files.

Thanks to JayRoxFox for rebasing this on current master!
9 years ago
Emmanuel Gil Peyrot 691a42fe98 VideoCore: Run include-what-you-use and fix most includes. 9 years ago
LittleWhite 9572652ddc Protect use of std::is_trivially_copyable to compile with GCC 4.9 9 years ago
Lioncash 5f51622e9d file_util: In-class initialize data members 9 years ago
Lioncash 655623ebb2 file_util: const qualify IOFile's Tell and GetSize functions 9 years ago
Lioncash a4120ca66c file_util: Don't expose IOFile internals through the API 9 years ago
Lioncash bf9945b81b file_util: Check for is_trivially_copyable
Also applies the template checks to ReadArray as well.
9 years ago