summaryrefslogtreecommitdiff
path: root/src/common/file_util.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* common: fs: Rework the Common Filesystem interface to make use of ↵Gravatar Morph2021-05-251-1032/+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-89/+350
| | | | | This reverts commit ce5fcb6bb2c358b0251a2ce87945bda52789a76d, reversing changes made to 6f41763061082d5fa2ab039c554427152243cb46.
* Revert "Merge pull request #5174 from ReinUsesLisp/fs-fix"Gravatar Morph2020-12-111-28/+2
| | | | | This reverts commit 5fe55b16a11d9ec607fb8a3fdddc77a4393cd96a, reversing changes made to e94dd7e2c4fc3f7ca2c15c01bdc301be2b8a4c1b.
* Revert "Merge pull request #5179 from ReinUsesLisp/fs-path"Gravatar Morph2020-12-111-1/+1
| | | | | This reverts commit 4e94d0d53af2cdb7b03ef9de23cc29f3565df97a, reversing changes made to 6d6115475b4edccdf1bb4e96ecc3d3b1be319e76.
* Revert "Merge pull request #5181 from Morph1984/5174-review"Gravatar Morph2020-12-111-3/+9
| | | | | This reverts commit cdb36aef9ec9d30bdef1953f9ed46776ae2f12af, reversing changes made to 5e9b77129f2cf8c039a8d98033cae4ac0f93f515.
* common/file_util: Simplify the behavior of CreateFullPathGravatar Morph2020-12-091-9/+3
|
* common/file_util: Let std::filesystem cast from UTF16 to std::stringGravatar ReinUsesLisp2020-12-091-1/+1
| | | | Fix invalid encoding paths when iterating over a directory on Windows.
* common/file_util: Fix and deprecate CreateFullPath, add CreateDirsGravatar ReinUsesLisp2020-12-091-2/+23
| | | | | | | | 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.
* common/file_util: Succeed on CreateDir when the directory existsGravatar ReinUsesLisp2020-12-091-0/+5
|
* file_util: Migrate remaining file handling functions over to std::filesystemGravatar Lioncash2020-12-091-297/+81
| | | | | | | 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-53/+8
| | | | Greatly simplifies our file-handling code for these functions.
* common: Enable warnings as errorsGravatar Lioncash2020-11-021-13/+18
| | | | Cleans up common so that we can enable warnings as errors.
* Merge pull request #4539 from lioncash/discGravatar bunnei2020-08-181-2/+2
|\ | | | | common: Silence two discarded result warnings
| * common: Silence two discarded result warningsGravatar Lioncash2020-08-161-2/+2
| | | | | | | | | | | | | | These are intentionally discarded internally, since the rest of the public API allows querying success. We want all non-internal uses of these functions to be explicitly checked, so we can signify that we intentionally want to discard the return values here.
* | common/fileutil: Convert namespace to Common::FSGravatar Lioncash2020-08-161-28/+36
|/ | | | | | | | | | | | 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: Add a screenshots directoryGravatar lat9nq2020-07-201-0/+1
| | | | Adds a screenshots directory as a path managed by FileUtil.
* Merge pull request #3630 from benru/open-windows-network-filesGravatar bunnei2020-04-171-1/+8
|\ | | | | common/file_util: Allow access to files on network shares
| * common/file_util: Allow access to files on network sharesGravatar Ben Russell2020-04-091-1/+8
| | | | | | | | | | | | | | | | 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).
* | file_util: Early-exit in WriteArray and ReadArray if specified lengths are zeroGravatar Lioncash2020-04-151-0/+28
|/ | | | | | | | | | | | | 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: Port some changes from dolphin (#5127)Gravatar Vitor K2020-04-011-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* common/file_util: Silence -WswitchGravatar ReinUsesLisp2019-10-041-1/+2
|
* common/file_util: Remove unnecessary return at end of void StripTailDirSlashes()Gravatar Lioncash2019-05-231-6/+8
| | | | While we're at it, also invert the conditional into a guard clause.
* common/file_util: Make GetCurrentDir() return a std::optionalGravatar Lioncash2019-05-231-2/+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: Remove duplicated documentation commentsGravatar Lioncash2019-05-231-25/+0
| | | | | These are already present within the header, so they don't need to be repeated in the cpp file.
* common/file_util: Make ReadFileToString and WriteStringToFile consistentGravatar Lioncash2019-05-231-3/+3
| | | | | | | | | | | 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.
* file_util: Add shader directoryGravatar ReinUsesLisp2019-02-061-0/+1
|
* only redefine 64 bit file operation for MSVCGravatar Weiyi Wang2018-10-231-5/+8
| | | | MinGW provides POSIX functions
* 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-8/+8
|
* file_util: Correct return value in early exit of ReadFileToString()Gravatar Lioncash2018-08-241-1/+1
| | | | | While still essentially being zero, we should be returning a numeric value here, not a boolean typed value.
* file_util: Add getter for NAND registration directoryGravatar Zach Hilman2018-08-111-0/+6
|
* file_util: Use enum instead of bool for specifing path behaviorGravatar Zach Hilman2018-08-081-4/+4
|
* file_util: Add platform-specific slash option to SanitizePathGravatar Zach Hilman2018-08-081-3/+13
|
* Allow key loading from %YUZU_DIR%/keys in addition to ~/.switchGravatar Zach Hilman2018-08-011-0/+1
|
* Use SHGetKnownFolderPath instead of SHGetFolderPathAGravatar Zach Hilman2018-08-011-3/+4
|
* Extract mbedtls to cpp fileGravatar Zach Hilman2018-08-011-1/+1
|
* Remove files that are not usedGravatar Zach Hilman2018-08-011-0/+12
|
* VFS Regression and Accuracy Fixes (#776)Gravatar Zach Hilman2018-07-231-1/+10
| | | | | | | | | | | | | | | | * 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&
* Merge pull request #768 from lioncash/string-viewGravatar bunnei2018-07-221-34/+48
|\ | | | | file_util, vfs: Use std::string_view where applicable
| * file_util, vfs: Use std::string_view where applicableGravatar Lioncash2018-07-221-34/+48
| | | | | | | | | | Avoids unnecessary construction of std::string instances where applicable.
* | Merge pull request #765 from lioncash/fileGravatar bunnei2018-07-221-24/+14
|\ \ | |/ |/| file_util: Remove goto usages from Copy()
| * file_util: Remove goto usages from Copy()Gravatar Lioncash2018-07-211-24/+14
| | | | | | | | | | | | 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.
* | file_util: Use a u64 to represent number of entriesGravatar Lioncash2018-07-211-9/+9
| | | | | | | | | | 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: std::move FST entries in ScanDirectoryTree()Gravatar Lioncash2018-07-211-1/+1
|/ | | | Avoids unnecessary copies when building up the FST entries.
* Merge pull request #759 from lioncash/redundantGravatar bunnei2018-07-211-2/+1
|\ | | | | file_util: Remove redundant duplicate return in GetPathWithoutTop()
| * file_util: Remove explicit type from std::min() in GetPathWithoutTop()Gravatar Lioncash2018-07-211-1/+1
| | | | | | | | | | Given both operands are the same type, there won't be an issue with overload selection that requires making this explicit.
| * file_util: Remove redundant duplicate return in GetPathWithoutTop()Gravatar Lioncash2018-07-211-1/+0
| |
* | file_util: Use an enum class for GetUserPath()Gravatar Lioncash2018-07-211-33/+35
|/ | | | | | | | | | | | | 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-26/+81
| | | | | | | | | | * Virtual Filesystem * Fix delete bug and documentate * Review fixes + other stuff * Fix puyo regression