2019-12-09 11:57:37 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2019-12-09 11:57:37 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
2021-10-01 02:21:08 +00:00
|
|
|
#include <stratosphere/fs/fs_common.hpp>
|
|
|
|
#include <stratosphere/fs/fs_istorage.hpp>
|
|
|
|
#include <stratosphere/fs/impl/fs_newable.hpp>
|
2019-12-09 11:57:37 +00:00
|
|
|
|
|
|
|
namespace ams::fs {
|
|
|
|
|
2020-03-08 08:06:23 +00:00
|
|
|
class RemoteStorage : public IStorage, public impl::Newable {
|
2019-12-09 11:57:37 +00:00
|
|
|
private:
|
2021-10-10 07:14:06 +00:00
|
|
|
std::unique_ptr<::FsStorage, impl::Deleter> m_base_storage;
|
2019-12-09 11:57:37 +00:00
|
|
|
public:
|
2020-03-08 08:06:23 +00:00
|
|
|
RemoteStorage(::FsStorage &s) {
|
2021-10-10 07:14:06 +00:00
|
|
|
m_base_storage = impl::MakeUnique<::FsStorage>();
|
|
|
|
*m_base_storage = s;
|
2019-12-09 11:57:37 +00:00
|
|
|
}
|
|
|
|
|
2021-10-10 07:14:06 +00:00
|
|
|
virtual ~RemoteStorage() { fsStorageClose(m_base_storage.get()); }
|
2019-12-09 11:57:37 +00:00
|
|
|
public:
|
|
|
|
virtual Result Read(s64 offset, void *buffer, size_t size) override {
|
2021-10-10 07:14:06 +00:00
|
|
|
return fsStorageRead(m_base_storage.get(), offset, buffer, size);
|
2019-12-09 11:57:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
|
2021-10-10 07:14:06 +00:00
|
|
|
return fsStorageWrite(m_base_storage.get(), offset, buffer, size);
|
2019-12-09 11:57:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual Result Flush() override {
|
2021-10-10 07:14:06 +00:00
|
|
|
return fsStorageFlush(m_base_storage.get());
|
2019-12-09 11:57:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual Result GetSize(s64 *out_size) override {
|
2021-10-10 07:14:06 +00:00
|
|
|
return fsStorageGetSize(m_base_storage.get(), out_size);
|
2019-12-09 11:57:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual Result SetSize(s64 size) override {
|
2021-10-10 07:14:06 +00:00
|
|
|
return fsStorageSetSize(m_base_storage.get(), size);
|
2019-12-09 11:57:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
|
|
|
|
/* TODO: How to deal with this? */
|
2021-10-07 00:58:42 +00:00
|
|
|
AMS_UNUSED(dst, dst_size, op_id, offset, size, src, src_size);
|
2019-12-09 11:57:37 +00:00
|
|
|
return fs::ResultUnsupportedOperation();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|