summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Subv2018-03-19 21:17:15 -0500
committerGravatar Subv2018-03-19 21:17:15 -0500
commitc4ca802b9dc7f0d3f3aed5aa937240bf85370c15 (patch)
tree12199ad7acfb7b1b886eda7ad01d968e10c9051c /src/core/file_sys
parentMerge pull request #251 from Subv/tic_tsc (diff)
downloadyuzu-c4ca802b9dc7f0d3f3aed5aa937240bf85370c15.tar.gz
yuzu-c4ca802b9dc7f0d3f3aed5aa937240bf85370c15.tar.xz
yuzu-c4ca802b9dc7f0d3f3aed5aa937240bf85370c15.zip
FS: Added an SDMC archive factory and registered it to the SDMC archive on startup.
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/sdmc_factory.cpp40
-rw-r--r--src/core/file_sys/sdmc_factory.h31
2 files changed, 71 insertions, 0 deletions
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp
new file mode 100644
index 000000000..00e80d2a7
--- /dev/null
+++ b/src/core/file_sys/sdmc_factory.cpp
@@ -0,0 +1,40 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <cinttypes>
6#include <memory>
7#include "common/common_types.h"
8#include "common/logging/log.h"
9#include "common/string_util.h"
10#include "core/core.h"
11#include "core/file_sys/disk_filesystem.h"
12#include "core/file_sys/sdmc_factory.h"
13
14namespace FileSys {
15
16SDMC_Factory::SDMC_Factory(std::string sd_directory) : sd_directory(std::move(sd_directory)) {}
17
18ResultVal<std::unique_ptr<FileSystemBackend>> SDMC_Factory::Open(const Path& path) {
19 // Create the SD Card directory if it doesn't already exist.
20 if (!FileUtil::IsDirectory(sd_directory)) {
21 FileUtil::CreateFullPath(sd_directory);
22 }
23
24 auto archive = std::make_unique<Disk_FileSystem>(sd_directory);
25 return MakeResult<std::unique_ptr<FileSystemBackend>>(std::move(archive));
26}
27
28ResultCode SDMC_Factory::Format(const Path& path) {
29 LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str());
30 // TODO(Subv): Find the right error code for this
31 return ResultCode(-1);
32}
33
34ResultVal<ArchiveFormatInfo> SDMC_Factory::GetFormatInfo(const Path& path) const {
35 LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str());
36 // TODO(bunnei): Find the right error code for this
37 return ResultCode(-1);
38}
39
40} // namespace FileSys
diff --git a/src/core/file_sys/sdmc_factory.h b/src/core/file_sys/sdmc_factory.h
new file mode 100644
index 000000000..93becda25
--- /dev/null
+++ b/src/core/file_sys/sdmc_factory.h
@@ -0,0 +1,31 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include <string>
9#include "common/common_types.h"
10#include "core/file_sys/filesystem.h"
11#include "core/hle/result.h"
12
13namespace FileSys {
14
15/// File system interface to the SDCard archive
16class SDMC_Factory final : public FileSystemFactory {
17public:
18 explicit SDMC_Factory(std::string sd_directory);
19
20 std::string GetName() const override {
21 return "SDMC_Factory";
22 }
23 ResultVal<std::unique_ptr<FileSystemBackend>> Open(const Path& path) override;
24 ResultCode Format(const Path& path) override;
25 ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path) const override;
26
27private:
28 std::string sd_directory;
29};
30
31} // namespace FileSys