Commit Graph

110 Commits

Author SHA1 Message Date
21df3ca572 StringUtil: Move IsPrintableCharacter() into Common namespace 2023-05-16 14:17:54 -04:00
3d767edd8a IOS/FS: Split FSDevice into FSCore and FSDevice.
FSCore implements the core functionality that can also be used outside of emulation. FSDevice implements the IOS device and is only available during emulation.
2023-05-15 20:41:47 +02:00
5373fcc1e7 IOS/FS: Filter files exposed to the emulated system in ReadDirectory() and GetDirectoryStats(). 2023-04-10 19:50:08 +02:00
5c05155828 IOS/FS: Implement GetNandStats(). 2023-04-10 19:50:08 +02:00
8295d6d415 IOS/FS: More accurate cluster calculation in GetDirectoryStats(). 2023-04-10 19:50:08 +02:00
69d6be09f7 IOS/FS: GetDirectoryStats() should return an error if the given path is not a directory. 2023-04-10 19:50:08 +02:00
e52aa52a66 Common/FileUtil: Rename Copy() to CopyRegularFile().
This is to clarify that it can only copy files, not folders.
2023-02-22 11:43:58 +01:00
e5b91f00b0 Common: Replace StringBeginsWith/StringEndsWith with std equivalents
Obsoletes these functions in favor of the standard member functions
added in C++20.
2023-01-24 14:58:20 -05:00
839db591d9 HW/Memmap: Refactor Memory to class, move to Core::System. 2022-12-03 13:27:02 +01:00
cc5640245c Fix build errors related to formatting non-scoped enums 2022-11-23 13:45:43 -08:00
ed54e1905a HostFileSystem: Set all NAND folders to be saved in save states when a movie is active 2022-11-10 14:02:29 -05:00
486a523e0d IOS: Simplify IOS::HLE::Device savestate method 2022-10-17 23:11:04 -04:00
0d39c4a78a IOS/FS: Skip writing FST if SetMetadata() changes nothing. 2022-08-10 06:28:23 +02:00
df22439826 FS: Reshuffle Rename to fix steamrt unit test failure 2022-05-29 13:50:32 -04:00
f6b9acccfc Common: Refactor PointerWrap 2022-05-25 13:06:41 -07:00
36cfcb530f IOFile: Make origin parameter to Seek() an enum class. 2022-01-29 06:49:21 +01:00
1a92699455 Cast to int for enums that are not formattable 2022-01-13 11:11:08 -08:00
0cc211d1ef Use fmt::format_string 2022-01-13 11:11:08 -08:00
e54657254a Core: Make format of D_WIIROOT_IDX consistent with the rest of the user directories. 2021-12-25 20:21:32 +01:00
2025763420 Treewide: Adjust order of includes 2021-12-10 14:49:57 -08:00
04d8cdfe88 Convert LOG_TYPE and LOG_LEVELS to enum class 2021-10-24 11:48:36 -07:00
0efff5167d IOS/FS: On NAND redirected files, the source and target of a Rename operation may be on different partitions or devices. Implement a fallback for that. 2021-10-24 00:09:09 +02:00
fe242f79ee Core: Implement Wii NAND path redirects for Riivolution savegame patches. 2021-10-24 00:09:07 +02:00
e149ad4f0a treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
391644dbb5 IOS/FS: Add a scoped FD class to make it harder to leak FDs
This changes FileSystemProxy::Open to return a file descriptor wrapper
that will ensure the FD is closed when it goes out of scope.

By using such a wrapper we make it more difficult to forget to close
file descriptors.

This fixes a leak in ReadBootContent. I should have added such a class
from the beginning... In practice, I don't think this would have caused
any obvious issue because ReadBootContent is only called after an IOS
relaunch -- which clears all FDs -- and most titles do not get close
to the FD limit.
2021-04-01 21:34:58 +02:00
bdaac718ac IOS/FS: Expose some more ioctls for internal Dolphin use 2021-03-04 18:41:13 +01:00
985ede9ca0 Core: Fix time base unit mixup
And add a strongly typed integer type so that making this kind of
mistake is more difficult
2021-02-20 14:18:21 +01:00
e3bf5fca93 IOS: Deduplicate IPC_OVERHEAD_TICKS timing constant 2021-02-18 21:10:55 +01:00
5eca82a6f2 IOS/ES: Allow various utility functions to return timing info 2021-02-18 18:53:33 +01:00
f214df5d2c IOS/FS: Allow IPC interface to be used internally from IOS HLE
This makes it more convenient to emulate timings for IPC commands that
perform internal IOS <-> IOS IPC, for example ES relying on FS
for filesystem access.
2021-02-18 18:53:32 +01:00
d0c91380c7 IOS/FS: Implement timings for older IOS versions as well
According to hwtests, older versions of IOS are slower at performing
various filesystem operations:

https://docs.google.com/spreadsheets/d/1OKo9IUuKCrniz4m0kYIaMP_qFtOCmAzHZ_zAmobvBcc/edit

(courtesy of JMC)

A quick glance at IOS9 reveals that older versions of IOS have a
simplistic implementation of memcpy that does not optimize large copies
by copying 16 bytes or 32 bytes per chunk, which makes cached reads
and writes noticeably slower -- the difference was significant enough
that the OoT speedrunning community noticed that IOS9 (the IOS that
is used for the OoT VC title) was slower.
2021-02-15 18:41:22 +01:00
d0136dd7c2 IOS: Clean up the way IPC replies are constructed
Instead of constructing IPCCommandResult with static member functions
in the Device class, we can just add the relevant constructors to the
reply struct itself. Makes more sense than putting it in Device
when the struct is used in the kernel code and doesn't use any Device
specific members...

This commit also changes the IPC command handlers to return an optional
IPCCommandResult rather than an IPCCommandResult. This removes the need
for a separate boolean that indicates whether the "result" is actually
a reply, and also avoids the need to set dummy result values and ticks.

It also makes it really obvious which commands can result in no reply
being generated.

Finally, this commit renames IPCCommandResult to IPCReply since the
struct is now only used for actual replies. This new name is less
verbose in my opinion.

The diff is quite large since this touches every command handler, but
the only functional change is that I fixed EnqueueIPCReply to
take a s64 for cycles_in_future to match IPCReply.
2021-02-13 20:15:30 +01:00
99fc1c682a IOS: Simplify unnecessarily qualified names
Now that the ES class (now called ESDevice) and the ES namespace do
not conflict anymore, "IOS::" can be dropped in a lot of cases.

This also removes "IOS::HLE::" for code that is already in that
namespace. Some of those names used to be explicitly qualified
only for historical reasons.

There are no functional changes.
2021-02-13 01:36:09 +01:00
522cb6b137 IOS: Use less ambiguous names for classes
Some of the device names can be ambiguous and require fully or partly
qualifying the name (e.g. IOS::HLE::FS::) in a somewhat verbose way.

Additionally, insufficiently qualified names are prone to breaking.
Consider the example of IOS::HLE::FS:: (namespace) and
IOS::HLE::Device::FS (class). If we use FS::Foo in a file that doesn't
know about the class, everything will work fine. However, as soon as
Device::FS is declared via a header include or even just forward
declared, that code will cease to compile because FS:: now resolves
to Device::FS if FS::Foo was used in the Device namespace.

It also leads to having to write IOS::ES:: to access ES types and
utilities even for code that is already under the IOS namespace.

The fix for this is simple: rename the device classes and give them
a "device" suffix in their names if the existing ones may be ambiguous.
This makes it clear whether we're referring to the device class or to
something else.

This is not any longer to type, considering it lets us get rid of the
Device namespace, which is now wholly unnecessary.

There are no functional changes in this commit.

A future commit will fix unnecessarily qualified names.
2021-02-12 21:40:31 +01:00
3193f3d5c4 rename Core/IOS/FS/FileSystem.cpp to FileSystemCommon.cpp 2021-01-27 14:29:48 -08:00
84128d9532 rename Common/File to Common/IOFile 2021-01-27 14:29:48 -08:00
f7d7bbf55f WiiUtils: Check hashes to determine if a title is installed and up-to-date
Nintendo's official title installation code and ES both only look at
content IDs but we should probably check for content hashes in addition
to checking for IDs for at least two reasons:

1. Some of the installed contents could be corrupted -- this cannot be
   easily detected without checking hashes.

2. Some mod distributors do not bother to update content IDs, which
   means that installing updates from the UI would not actually
   update the installed game. This is confusing for users.

To keep the existing semantic (for IOS especially), the new content
hash checks are opt-in for callers of GetStoredContentsFromTMD.

This commit changes WiiUtils's WAD installation logic to enable
the content hash checks.
2020-12-06 01:53:55 +01:00
6cd718163f Core: Convert logging over to fmt pt.4
Continues the migration of logging in the Core library. This part
finishes up the remaining log calls within the IOS code.
2020-11-23 11:53:21 -05:00
9a5a705d01 Fix comparison to invalidated vector iterator.
GetFstEntryForPath may modify the children vector,
so do it before taking an iterator to the vector.
2020-08-16 15:17:11 -07:00
b2cf106ae9 IOS/FS: Fix FST write failure on some platforms
On some platforms (like Windows), the temporary file must be closed
before it can be renamed.

I guess nobody noticed this for so long because (1) the FS code has a
failsafe for missing FST entries (because existing users do not have
a FST), and most games do not care about file metadata;
(2) the write failures can only be seen in the logs.

Because we don't want this to break, I have turned the ERROR_LOGs into
PanicAlerts.
2020-04-18 12:42:12 +02:00
bbc8631357 IOS/FS: Fix CreateFullPath to not create directories that already exist
This fixes CreateFullPath to not create directories when it is known
that they already exist, instead of calling CreateDirectory anyway
and checking if the error is AlreadyExists. (That doesn't work
now that we have an accurate implementation of CreateDirectory
that performs permission checks before checking for existence.)

I'm not sure what I was thinking when I wrote that function.

Also adds some tests for CreateFullPath.
2020-01-30 18:07:03 +01:00
d4ba0acb3a UnitTests/FS: Add path validity and splitting tests 2020-01-25 17:54:57 +01:00
484cfb9328 UnitTests/FS: Add metadata tests 2020-01-25 17:53:39 +01:00
142b7e048b IOS/FS: Actually implement SetMetadata 2020-01-25 17:53:35 +01:00
e4dd582d1d IOS/FS: Implement GetMetadata properly and remove GID hack
Now that all FS functions that create new inodes are properly
implemented, we can make GetMetadata actually return correct file
metadata rather than giving fixed information. The hack for the DQX
installer can also be removed now since our ES and FS keep track of
caller UID/GIDs now.
2020-01-25 17:53:34 +01:00
396429d582 IOS/FS: Implement ReadDirectory properly and remove sorting hack
With the CreateFile/CreateDirectory fix and this commit, we can
finally return correct results in ReadDirectory and the sorting
hack -- whose purpose was to prevent certain versions of the
System Menu from crashing -- can be removed too.
2020-01-25 17:53:19 +01:00
a40f297d1d IOS/FS: Implement Rename properly 2020-01-25 17:53:18 +01:00
53ceb6c693 IOS/FS: Implement Delete properly 2020-01-25 17:53:05 +01:00
8517528f8c IOS/FS: Implement CreateFile and CreateDir properly 2020-01-25 17:52:45 +01:00
36676d2628 IOS/FS: Implement Format properly 2020-01-25 17:52:03 +01:00