A bit of a redesign.

Sessions and Ports are now detached from each other.
HLE services are handled by means of a SessionRequestHandler class, Interface now inherits from this class.
The File and Directory classes are no longer kernel objects, but SessionRequestHandlers instead, bound to a ServerSession when requested.
File::OpenLinkFile now creates a new session pair and binds the File instance to it.
This commit is contained in:
Subv
2016-11-30 22:50:13 -05:00
parent c5e7e0fa26
commit 009b15b3aa
13 changed files with 266 additions and 263 deletions

View File

@ -41,32 +41,32 @@ enum class MediaType : u32 { NAND = 0, SDMC = 1 };
typedef u64 ArchiveHandle;
class File : public Kernel::ServerSession {
class File : public SessionRequestHandler, public std::enable_shared_from_this<File> {
public:
File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path);
~File();
std::string GetName() const override {
std::string GetName() const {
return "Path: " + path.DebugStr();
}
ResultCode HandleSyncRequest() override;
ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
FileSys::Path path; ///< Path of the file
u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
};
class Directory : public Kernel::ServerSession {
class Directory : public SessionRequestHandler {
public:
Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path);
~Directory();
std::string GetName() const override {
std::string GetName() const {
return "Directory: " + path.DebugStr();
}
ResultCode HandleSyncRequest() override;
ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
FileSys::Path path; ///< Path of the directory
std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
@ -99,9 +99,9 @@ ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factor
* @param archive_handle Handle to an open Archive object
* @param path Path to the File inside of the Archive
* @param mode Mode under which to open the File
* @return The opened File object as a Session
* @return The opened File object
*/
ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
ResultVal<std::shared_ptr<File>> OpenFileFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path,
const FileSys::Mode mode);
@ -178,9 +178,9 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
* Open a Directory from an Archive
* @param archive_handle Handle to an open Archive object
* @param path Path to the Directory inside of the Archive
* @return The opened Directory object as a Session
* @return The opened Directory object
*/
ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
ResultVal<std::shared_ptr<Directory>> OpenDirectoryFromArchive(ArchiveHandle archive_handle,
const FileSys::Path& path);
/**