/* * Copyright (c) Atmosphère-NX * * 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 . */ #pragma once #include namespace ams::fssystem { class DirectorySaveDataFileSystem : public impl::IPathResolutionFileSystem { NON_COPYABLE(DirectorySaveDataFileSystem); private: using PathResolutionFileSystem = impl::IPathResolutionFileSystem; friend class impl::IPathResolutionFileSystem; private: os::SdkMutex m_accessor_mutex; s32 m_open_writable_files; public: DirectorySaveDataFileSystem(std::shared_ptr fs); DirectorySaveDataFileSystem(std::unique_ptr fs); Result Initialize(); virtual ~DirectorySaveDataFileSystem(); protected: inline util::optional> GetAccessorLock() { /* We have a real accessor lock that we want to use. */ return util::make_optional>(m_accessor_mutex); } private: Result AllocateWorkBuffer(std::unique_ptr *out, size_t *out_size, size_t ideal_size); Result SynchronizeDirectory(const char *dst, const char *src); Result ResolveFullPath(char *out, size_t out_size, const char *relative_path); public: void OnWritableFileClose(); Result CopySaveFromFileSystem(fs::fsa::IFileSystem *save_fs); public: /* Overridden from IPathResolutionFileSystem */ virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) override; virtual Result DoCommit() override; /* Overridden from IPathResolutionFileSystem but not commands. */ virtual Result DoCommitProvisionally(s64 counter) override; virtual Result DoRollback() override; /* Explicitly overridden to be not implemented. */ virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override; virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override; virtual Result DoGetFileTimeStampRaw(fs::FileTimeStampRaw *out, const char *path) override; virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const char *path) override; virtual Result DoFlush() override; }; }