From 071663e07423cac6037c72153edafea1efe9da9f Mon Sep 17 00:00:00 2001 From: Subv Date: Sat, 7 Feb 2015 13:06:48 -0500 Subject: Archives: Expose the File and Directory classes to HLE --- src/core/hle/service/fs/archive.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/fs/archive.h') diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 3d9b8a76..e27ad7d6 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h @@ -8,6 +8,7 @@ #include "core/file_sys/archive_backend.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/session.h" #include "core/hle/result.h" /// The unique system identifier hash, also known as ID0 @@ -36,6 +37,35 @@ enum class ArchiveIdCode : u32 { typedef u64 ArchiveHandle; +class File : public Kernel::Session { +public: + File(std::unique_ptr&& backend, const FileSys::Path& path) + : path(path), priority(0), backend(std::move(backend)) { + } + + std::string GetName() const override { return "Path: " + path.DebugStr(); } + + FileSys::Path path; ///< Path of the file + u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means + std::unique_ptr backend; ///< File backend interface + + ResultVal SyncRequest() override; +}; + +class Directory : public Kernel::Session { +public: + Directory(std::unique_ptr&& backend, const FileSys::Path& path) + : path(path), backend(std::move(backend)) { + } + + std::string GetName() const override { return "Directory: " + path.DebugStr(); } + + FileSys::Path path; ///< Path of the directory + std::unique_ptr backend; ///< File backend interface + + ResultVal SyncRequest() override; +}; + /** * Opens an archive * @param id_code IdCode of the archive to open @@ -64,7 +94,7 @@ ResultCode RegisterArchiveType(std::unique_ptr&& factor * @param mode Mode under which to open the File * @return The opened File object as a Session */ -ResultVal> OpenFileFromArchive(ArchiveHandle archive_handle, +ResultVal> OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path, const FileSys::Mode mode); /** @@ -128,7 +158,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons * @param path Path to the Directory inside of the Archive * @return The opened Directory object as a Session */ -ResultVal> OpenDirectoryFromArchive(ArchiveHandle archive_handle, +ResultVal> OpenDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path); /** -- cgit v1.2.3