Commit graph

40 commits

Author SHA1 Message Date
Lioncash
c4f04533d9 filesystem: Make CreateFactories() and InstallInterface() take a VfsFilesystem instance by reference
Neither of these functions alter the ownership of the provided pointer,
so we can simply make the parameters a reference rather than a direct
shared pointer alias. This way we also disallow passing incorrect memory values like
nullptr.
2018-10-13 11:36:35 -04:00
Zach Hilman
598ca547b2 romfs_factory: Extract packed update setter to new function 2018-10-05 08:53:51 -04:00
Zach Hilman
80c76da1e1 filesystem: Add LayeredFS VFS directory getter 2018-09-21 19:53:33 -04:00
David Marcec
d24d803e6a Fixed GetAccountId stub, Added error code for OpenDirectory and added ActivateNpadWithRevision
With these, `Nintendo Entertainment System - Nintendo Switch Online` loads
2018-09-19 23:25:00 +10:00
Lioncash
8a9b062587 hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.

The cause of the above mentioned non-obvious errors can be demonstrated
as follows:

------- Demonstrative example, if you know how the described error happens, skip forwards -------

Assume we have the following in the header, which we'll call "thing.h":

\#include <memory>

// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;

class Thing {
public:
    // assume no constructors or destructors are specified here,
    // or the constructors/destructors are defined as:
    //
    // Thing() = default;
    // ~Thing() = default;
    //

    // ... Some interface member functions would be defined here

private:
    std::shared_ptr<Object> obj;
};

If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:

1. Decrement the shared reference count of the object being pointed to,
   and if the reference count decrements to zero,

2. Free the Object instance's memory (aka deallocate the memory it's
   pointing to).

And so the compiler generates the code for the destructor doing this inside main.cpp.

Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.

Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.

---------------------- End example ----------------------------

Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 23:55:31 -04:00
Zach Hilman
46eb9ec6ba bktr: Fix bucket overlap error 2018-09-04 17:01:54 -04:00
Zach Hilman
6e6f8cf474 registration: Add RegisteredCacheUnion
Aggregates multiple caches into one interface
2018-09-04 16:21:40 -04:00
Lioncash
92e7a2f7ff filesystem: Move dir retrieval after path checking in DeleteFile()
We don't need to do the lookup if the path is considered empty
currently.
2018-09-02 09:20:17 -04:00
Sebastian Valle
b151ff8867 Merge pull request #1166 from lioncash/typo
filesystem: Fix typo in log message
2018-08-25 07:19:46 -05:00
Lioncash
7ef364366f filesystem: Fix typo in log message 2018-08-23 22:12:31 -04:00
Zach Hilman
b8f5034fe1 filesystem: Add CreateFactories methods to fs
Allows frontend to create registration caches for use before a game has booted.
2018-08-23 11:52:44 -04:00
Zach Hilman
af6c9bb950 filesystem: Add logging to registration getters 2018-08-23 11:52:44 -04:00
Lioncash
e1124b6510 vfs: Replace mode.h include with forward declarations where applicable
Avoids the need to rebuild these source files if the mode header
changes.
2018-08-21 15:06:42 -04:00
Lioncash
1d77a31e1d service/filesystem: Use forward declarations where applicable
Avoids the need to rebuild multiple source files if the filesystem code
headers change.

This also gets rid of a few instances of indirect inclusions being
relied upon
2018-08-20 23:28:46 -04:00
Zach Hilman
350941e45e filesystem: Add support for loading of system archives 2018-08-18 21:28:23 -04:00
Zach Hilman
e891974118 filesystem: Add Open and Register functions for BISFactory 2018-08-11 22:50:48 -04:00
Zach Hilman
4cbef33915 core: Port core to VfsFilesystem for file access 2018-08-08 21:18:45 -04:00
Zach Hilman
653257de93 filesystem: Remove unnecessary if conditions 2018-08-08 21:18:45 -04:00
Lioncash
1d3dfe7e22 service/filesystem: Add fsp:ldr and fsp:pr services
Adds the basic skeleton for the remaining fsp services based off
information provided by Switch Brew.
2018-08-01 17:01:29 -04:00
Zach Hilman
bd410ce242 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&
2018-07-23 19:40:35 -07:00
Lioncash
861405d6c0 file_util, vfs: Use std::string_view where applicable
Avoids unnecessary construction of std::string instances where
applicable.
2018-07-22 03:22:21 -04:00
Lioncash
85ca923ed4 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.
2018-07-21 16:21:19 -04:00
Sebastian Valle
ee244af2f4 Merge pull request #720 from Subv/getentrytype_root
Filesystem: Return EntryType::Directory for the root directory.
2018-07-19 15:23:32 -05:00
Subv
c1b5369f60 Filesystem: Return EntryType::Directory for the root directory.
It is unknown if this is correct behavior, but it makes sense and fixes a regression with Stardew Valley.
2018-07-19 13:11:09 -05:00
Lioncash
043ab179b5 filesystem: std::move VirtualDir instance in VfsDirectoryServiceWrapper's constructor
Avoids unnecessary atomic reference count incrementing and decrementing
2018-07-19 10:34:11 -04:00
Lioncash
7ab5eb948c filesystem: Use std::string's empty() function instead of comparing against a literal
This is simply a basic value check as opposed to potentially doing
string based operations (unlikely, but still, avoiding it is free).
2018-07-19 10:32:23 -04:00
Lioncash
9dccecb6b0 filesystem: Remove pragma disabling global optimizations
This was just an artifact missed during PR review.
2018-07-19 10:30:53 -04:00
Zach Hilman
82150bd5c1 Virtual Filesystem 2: Electric Boogaloo (#676)
* Virtual Filesystem

* Fix delete bug and documentate

* Review fixes + other stuff

* Fix puyo regression
2018-07-18 18:07:11 -07:00
Zach Hilman
753d85fb0c General Filesystem and Save Data Fixes (#670) 2018-07-17 12:42:15 -07:00
bunnei
0c22a8d514 Revert "Virtual Filesystem (#597)"
This reverts commit 12e9522b32.
2018-07-07 20:24:51 -07:00
Zach Hilman
12e9522b32 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
2018-07-06 10:51:32 -04:00
James Rowe
d74d2a77cb Update clang format 2018-07-02 21:45:47 -04:00
James Rowe
e159c550d8 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Lioncash
1b310cbb3a general: Make formatting of logged hex values more straightforward
This makes the formatting expectations more obvious (e.g. any zero padding specified
is padding that's entirely dedicated to the value being printed, not any pretty-printing
that also gets tacked on).
2018-05-02 09:49:36 -04:00
Lioncash
7995e92e19 filesystem: Move logging macros over to new fmt-compatible ones 2018-04-24 12:00:52 -04:00
Lioncash
6d94dd21a5 service: Use nested namespace specifiers where applicable
Tidies up namespace declarations
2018-04-19 22:20:28 -04:00
Subv
a079723254 FS: Added an SDMC archive factory and registered it to the SDMC archive on startup. 2018-03-19 21:17:15 -05:00
Subv
9702f6c2ed FS: Make EnsureSaveData create the savedata folder when called for the first time. 2018-03-04 14:30:07 -05:00
Subv
dfdc72efa7 Filesystem: Added a SaveData Factory and associated Disk_FileSystem. 2018-03-01 19:03:52 -05:00
David Marcec
b609697364 filesystem: Implement basic IStorage functionality. 2018-01-21 15:39:28 -05:00