Serialize file/directory services

This commit is contained in:
Hamish Milne 2020-01-10 23:47:39 +00:00 committed by zhupengfei
parent 9525d81344
commit ca971ff31f
7 changed files with 81 additions and 3 deletions

View file

@ -2,13 +2,25 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "common/logging/log.h"
#include "core/file_sys/directory_backend.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/fs/directory.h"
SERIALIZE_EXPORT_IMPL(Service::FS::Directory)
namespace Service::FS {
template <class Archive>
void Directory::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& path;
ar& backend;
}
Directory::Directory() : ServiceFramework("", 1) {}
Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend,
const FileSys::Path& path)
: ServiceFramework("", 1), path(path), backend(std::move(backend)) {

View file

@ -25,6 +25,15 @@ public:
protected:
void Read(Kernel::HLERequestContext& ctx);
void Close(Kernel::HLERequestContext& ctx);
private:
Directory();
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
} // namespace Service::FS
BOOST_CLASS_EXPORT_KEY(Service::FS::Directory)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "common/logging/log.h"
#include "core/core.h"
#include "core/file_sys/errors.h"
@ -13,8 +14,20 @@
#include "core/hle/kernel/server_session.h"
#include "core/hle/service/fs/file.h"
SERIALIZE_EXPORT_IMPL(Service::FS::File)
SERIALIZE_EXPORT_IMPL(Service::FS::FileSessionSlot)
namespace Service::FS {
template <class Archive>
void File::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& path;
ar& backend;
}
File::File() : ServiceFramework("", 1), kernel(Core::Global<Kernel::KernelSystem>()) {}
File::File(Kernel::KernelSystem& kernel, std::unique_ptr<FileSys::FileBackend>&& backend,
const FileSys::Path& path)
: ServiceFramework("", 1), path(path), backend(std::move(backend)), kernel(kernel) {

View file

@ -6,6 +6,7 @@
#include <memory>
#include "core/file_sys/archive_backend.h"
#include "core/global.h"
#include "core/hle/service/service.h"
namespace Core {
@ -30,6 +31,7 @@ private:
ar& size;
ar& subfile;
}
friend class boost::serialization::access;
};
// TODO: File is not a real service, but it can still utilize ServiceFramework::RegisterHandlers.
@ -71,6 +73,15 @@ private:
void OpenSubFile(Kernel::HLERequestContext& ctx);
Kernel::KernelSystem& kernel;
File();
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
} // namespace Service::FS
BOOST_CLASS_EXPORT_KEY(Service::FS::FileSessionSlot)
BOOST_CLASS_EXPORT_KEY(Service::FS::File)