Commit Graph

112 Commits (f98a2c42dee1a3c20f4a4e876069a32982395f05)

Author SHA1 Message Date
Ben Russell f98a2c42de
common/file_util: Allow access to files on network shares
On Windows, network shares use paths like \\server\share\file which were
being broken by FileUtil::SanitizePath() removing double slashes.

Changed the code in SanitizePath to permit a double-backslash if it
occurs at the start of a filepath (on Windows only).
5 years ago
Vitor K bd0c56c6e7 common: Port some changes from dolphin (#5127)
* IOFile: Make the move constructor and move assignment operator noexcept

Certain parts of the standard library try to determine whether or not a
transfer operation should either be a copy or a move. The prevalent notion
of move constructors/assignment operators is that they should not throw,
they simply move an already existing resource somewhere else.

This is typically done with 'std::move_if_noexcept'. Like the name says,
if a type's move constructor is noexcept, then the functions retrieves an
r-value reference (for move semantics), or an l-value (for copy semantics)
if it is not noexcept.

As IOFile deletes the copy constructor and copy assignment operators,
using IOFile with certain parts of the standard library can fail in
unexcepted ways (especially when used with various container
implementations). This prevents that.

* fix various instances of -1 being assigned to unsigned types

* do not assign in conditional statements

* File/IOFile: Check _tfopen_s properly

* common/file_util.cpp: address review comments

Co-authored-by: Lioncash <mathew1800@gmail.com>
Co-authored-by: Shawn Hoffman <godisgovernment@gmail.com>
Co-authored-by: Sepalani <sepalani@hotmail.fr>
5 years ago
ReinUsesLisp f4417eab8f common/file_util: Silence -Wswitch 6 years ago
Lioncash e7ab0e9127 common/file_util: Remove unnecessary return at end of void StripTailDirSlashes()
While we're at it, also invert the conditional into a guard clause.
6 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 943f6da1ac 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.
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
ReinUsesLisp 84412591c9 file_util: Add shader directory 6 years ago
Weiyi Wang 2ff2732a78 only redefine 64 bit file operation for MSVC
MinGW provides POSIX functions
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
Lioncash c74b7ee204 file_util: Correct return value in early exit of ReadFileToString()
While still essentially being zero, we should be returning a numeric
value here, not a boolean typed value.
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
Zach Hilman 150527ec19 Allow key loading from %YUZU_DIR%/keys in addition to ~/.switch 7 years ago
Zach Hilman cc8234fa89 Use SHGetKnownFolderPath instead of SHGetFolderPathA 7 years ago
Zach Hilman 22342487e8 Extract mbedtls to cpp file 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
bunnei 5ee4c49c30
Merge pull request #768 from lioncash/string-view
file_util, vfs: Use std::string_view where applicable
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
bunnei 258a5cee84
Merge pull request #765 from lioncash/file
file_util: Remove goto usages from Copy()
7 years ago
Lioncash c5de0a67a8 file_util: Remove goto usages from Copy()
We can just leverage std::unique_ptr to automatically close these for us
in error cases instead of jumping to the end of the function to call
fclose on them.
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 964154ce44 file_util: std::move FST entries in ScanDirectoryTree()
Avoids unnecessary copies when building up the FST entries.
7 years ago
bunnei 53a219f163
Merge pull request #759 from lioncash/redundant
file_util: Remove redundant duplicate return in GetPathWithoutTop()
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 34d6a1349c file_util: Remove explicit type from std::min() in GetPathWithoutTop()
Given both operands are the same type, there won't be an issue with
overload selection that requires making this explicit.
7 years ago
Lioncash 41660c8923 file_util: Remove redundant duplicate return in GetPathWithoutTop() 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
bunnei bebe09a1aa
Merge pull request #630 from FearlessTobi/remove-citra-references
Remove some references to Citra
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
fearlessTobi c9aadff9a9 Remove some references to Citra 7 years ago
James Rowe 6269a01b4e Add configurable logging backends 7 years ago
James Rowe 0d46f0df12 Update clang format 7 years ago
James Rowe 638956aa81 Rename logging macro back to LOG_* 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 8475496630
general: Convert assertion macros over to be fmt-compatible 7 years ago
Lioncash 3cfe77ae75
common: Move logging macros over to new fmt-capable macros where applicable 7 years ago
James Rowe 096be16636 Format: Run the new clang format on everything 7 years ago
wwylele d040a73bed file_util: Log when using local user directory 8 years ago
wwylele 7cd6cc0fd9 file_util: lower logging level for harmless cases 8 years ago
noah the goodra a2d0e2d807 file_util: Fixed implicit type conversion warning (#2503) 8 years ago
wwylele 488b7a4041 file_util: fix missing sysdata path 8 years ago
bunnei 707cc66362 file_util: Remove unused paths. 8 years ago
Jeffrey Pfau fb952c399e Common: Fix gcc build on macOS 8 years ago
freiro 0c22e52f52 WINVER definition moved to CMake and cleanup 9 years ago