summaryrefslogtreecommitdiff
path: root/src/common/file_util.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* common: fs: Rework the Common Filesystem interface to make use of ↵Gravatar Morph2021-05-251-298/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::filesystem (#6270) * common: fs: fs_types: Create filesystem types Contains various filesystem types used by the Common::FS library * common: fs: fs_util: Add std::string to std::u8string conversion utility * common: fs: path_util: Add utlity functions for paths Contains various utility functions for getting or manipulating filesystem paths used by the Common::FS library * common: fs: file: Rewrite the IOFile implementation * common: fs: Reimplement Common::FS library using std::filesystem * common: fs: fs_paths: Add fs_paths to replace common_paths * common: fs: path_util: Add the rest of the path functions * common: Remove the previous Common::FS implementation * general: Remove unused fs includes * string_util: Remove unused function and include * nvidia_flags: Migrate to the new Common::FS library * settings: Migrate to the new Common::FS library * logging: backend: Migrate to the new Common::FS library * core: Migrate to the new Common::FS library * perf_stats: Migrate to the new Common::FS library * reporter: Migrate to the new Common::FS library * telemetry_session: Migrate to the new Common::FS library * key_manager: Migrate to the new Common::FS library * bis_factory: Migrate to the new Common::FS library * registered_cache: Migrate to the new Common::FS library * xts_archive: Migrate to the new Common::FS library * service: acc: Migrate to the new Common::FS library * applets/profile: Migrate to the new Common::FS library * applets/web: Migrate to the new Common::FS library * service: filesystem: Migrate to the new Common::FS library * loader: Migrate to the new Common::FS library * gl_shader_disk_cache: Migrate to the new Common::FS library * nsight_aftermath_tracker: Migrate to the new Common::FS library * vulkan_library: Migrate to the new Common::FS library * configure_debug: Migrate to the new Common::FS library * game_list_worker: Migrate to the new Common::FS library * config: Migrate to the new Common::FS library * configure_filesystem: Migrate to the new Common::FS library * configure_per_game_addons: Migrate to the new Common::FS library * configure_profile_manager: Migrate to the new Common::FS library * configure_ui: Migrate to the new Common::FS library * input_profiles: Migrate to the new Common::FS library * yuzu_cmd: config: Migrate to the new Common::FS library * yuzu_cmd: Migrate to the new Common::FS library * vfs_real: Migrate to the new Common::FS library * vfs: Migrate to the new Common::FS library * vfs_libzip: Migrate to the new Common::FS library * service: bcat: Migrate to the new Common::FS library * yuzu: main: Migrate to the new Common::FS library * vfs_real: Delete the contents of an existing file in CreateFile Current usages of CreateFile expect to delete the contents of an existing file, retain this behavior for now. * input_profiles: Don't iterate the input profile dir if it does not exist Silences an error produced in the log if the directory does not exist. * game_list_worker: Skip parsing file if the returned VfsFile is nullptr Prevents crashes in GetLoader when the virtual file is nullptr * common: fs: Validate paths for path length * service: filesystem: Open the mod load directory as read only
* Revert "Merge pull request #5173 from lioncash/common-fs"Gravatar Morph2020-12-111-23/+46
| | | | | This reverts commit ce5fcb6bb2c358b0251a2ce87945bda52789a76d, reversing changes made to 6f41763061082d5fa2ab039c554427152243cb46.
* Revert "Merge pull request #5174 from ReinUsesLisp/fs-fix"Gravatar Morph2020-12-111-8/+2
| | | | | This reverts commit 5fe55b16a11d9ec607fb8a3fdddc77a4393cd96a, reversing changes made to e94dd7e2c4fc3f7ca2c15c01bdc301be2b8a4c1b.
* common/file_util: Fix and deprecate CreateFullPath, add CreateDirsGravatar ReinUsesLisp2020-12-091-2/+8
| | | | | | | | Fix CreateFullPath to have its intended previous behavior (whatever that was), and deprecate it in favor of the new CreateDirs function. Unlike CreateDir, CreateDirs is marked as [[nodiscard]] to avoid new code ignoring its result value.
* file_util: Migrate remaining file handling functions over to std::filesystemGravatar Lioncash2020-12-091-43/+19
| | | | | | | Converts creation and deletion functions over to std::filesystem, simplifying our file-handling code. Notably with this, CopyDir will now function on Windows.
* file_util: Migrate Exists() and IsDirectory() over to std::filesystemGravatar Lioncash2020-12-081-4/+5
| | | | Greatly simplifies our file-handling code for these functions.
* General: Make ignoring a discarded return value an errorGravatar Lioncash2020-10-301-1/+1
| | | | | | | Allows our CI to catch more potential bugs. This also removes the [[nodiscard]] attribute of IOFile's Open member function. There are cases where a file may want to be opened, but have the status of it checked at a later time.
* Revert "core: Fix clang build"Gravatar bunnei2020-10-201-2/+1
|
* core: Fix clang buildGravatar Lioncash2020-10-171-1/+2
| | | | | | | Recent changes to the build system that made more warnings be flagged as errors caused building via clang to break. Fixes #4795
* common/fileutil: Convert namespace to Common::FSGravatar Lioncash2020-08-161-12/+12
| | | | | | | | | | | | 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.
* common: Make use of [[nodiscard]] where applicableGravatar Lioncash2020-08-151-27/+34
| | | | | | 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.
* common: Add a screenshots directoryGravatar lat9nq2020-07-201-0/+1
| | | | Adds a screenshots directory as a path managed by FileUtil.
* file_util: Early-exit in WriteArray and ReadArray if specified lengths are zeroGravatar Lioncash2020-04-151-9/+5
| | | | | | | | | | | | | 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.
* common/file_util: Make GetCurrentDir() return a std::optionalGravatar Lioncash2019-05-231-1/+2
| | | | | | | | | | | 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: Make ReadFileToString and WriteStringToFile consistentGravatar Lioncash2019-05-231-2/+2
| | | | | | | | | | | 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 unnecessary c_str() callsGravatar Lioncash2019-05-231-2/+2
| | | | | | 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 IOFile's WriteString take a std::string_viewGravatar Lioncash2019-05-231-2/+2
| | | | | | 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.
* file_util: Add shader directoryGravatar ReinUsesLisp2019-02-061-0/+1
|
* string_util: remove TString conversion for windowsGravatar Weiyi Wang2018-10-021-1/+1
| | | | 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.
* common_paths: Add Load and Dump dirsGravatar Zach Hilman2018-09-211-0/+2
|
* Port #4182 from Citra: "Prefix all size_t with std::"Gravatar fearlessTobi2018-09-151-12/+13
|
* file_util: Add getter for NAND registration directoryGravatar Zach Hilman2018-08-111-0/+2
|
* file_util: Use enum instead of bool for specifing path behaviorGravatar Zach Hilman2018-08-081-2/+5
|
* file_util: Add platform-specific slash option to SanitizePathGravatar Zach Hilman2018-08-081-2/+3
|
* Merge pull request #966 from lioncash/modernizeGravatar bunnei2018-08-081-5/+5
|\ | | | | common: Convert type traits templates over to variable template versions where applicable
| * common: Convert type traits templates over to variable template versions ↵Gravatar Lioncash2018-08-071-5/+5
| | | | | | | | | | | | where applicable Uses the C++17 inline variable variants
* | file_util: Avoid sign-conversions in WriteArray() and ReadArray()Gravatar Lioncash2018-08-071-4/+8
|/ | | | Prevents compiler warnings.
* Allow key loading from %YUZU_DIR%/keys in addition to ~/.switchGravatar Zach Hilman2018-08-011-0/+1
|
* Remove files that are not usedGravatar Zach Hilman2018-08-011-0/+2
|
* VFS Regression and Accuracy Fixes (#776)Gravatar Zach Hilman2018-07-231-0/+3
| | | | | | | | | | | | | | | | * 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&
* file_util, vfs: Use std::string_view where applicableGravatar Lioncash2018-07-221-6/+7
| | | | | Avoids unnecessary construction of std::string instances where applicable.
* file_util: Use a u64 to represent number of entriesGravatar Lioncash2018-07-211-4/+4
| | | | | 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.
* file_util: Use an enum class for GetUserPath()Gravatar Lioncash2018-07-211-14/+13
| | | | | | | | | | | | | 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.
* file_util: return string by const reference for GetExeDirectory()Gravatar Lioncash2018-07-191-1/+1
| | | | | This disallows modifying the internal string buffer (which shouldn't be modified anyhow).
* Virtual Filesystem 2: Electric Boogaloo (#676)Gravatar Zach Hilman2018-07-181-31/+35
| | | | | | | | | | * Virtual Filesystem * Fix delete bug and documentate * Review fixes + other stuff * Fix puyo regression
* Revert "Virtual Filesystem (#597)"Gravatar bunnei2018-07-071-32/+31
| | | | This reverts commit 77c684c1140f6bf3fb7d4560d06d2efb1a2ee5e2.
* Virtual Filesystem (#597)Gravatar Zach Hilman2018-07-061-31/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Add configurable logging backendsGravatar James Rowe2018-07-021-2/+9
|
* file_util: Make move constructor/assignment operator and related functions ↵Gravatar Lioncash2018-04-291-3/+3
| | | | | | | | | 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.
* file_util: Add static assertions to ReadBytes() and WriteBytes()Gravatar Lioncash2018-04-291-2/+6
| | | | | | 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.
* file_util: Remove compiler version checks around is_trivially_copyable()Gravatar Lioncash2018-04-281-8/+0
| | | | | | 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.
* file_util.h: Update Comment from citra to yuzuGravatar N00byKing2018-03-261-1/+1
|
* Format: Run the new clang format on everythingGravatar James Rowe2018-01-201-1/+1
|
* file_util: Remove unused paths.Gravatar bunnei2016-12-211-20/+0
|
* Switch to AppData/RoamingGravatar freiro2016-11-241-1/+1
|
* Return by value and other fixesGravatar freiro2016-11-191-1/+1
|
* Win32 move default user folder location to AppDataGravatar freiro2016-11-191-0/+1
|
* Remove empty newlines in #include blocks.Gravatar Emmanuel Gil Peyrot2016-09-211-2/+0
| | | | | | | This makes clang-format useful on those. Also add a bunch of forgotten transitive includes, which otherwise prevented compilation.
* Sources: Run clang-format on everything.Gravatar Emmanuel Gil Peyrot2016-09-181-55/+63
|
* Fix recursive scanning of directoriesGravatar Yuri Kunde Schlesner2016-06-191-5/+2
| | | | | | 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.