summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-03-03 18:25:51 +0100
committerLéo Lam <leo@innovatetechnologi.es>2018-03-31 10:45:44 +0200
commitfcfe4e2a26ca02b242435edb91179c4a749b1ea8 (patch)
tree1d4f489a170c1369be95b383aaef770636962f4c
parent1eec459e308bd41d492b515229e318dcaf121251 (diff)
IOS: Change GetFS() to return a FileSystem
Now that we have a proper filesystem interface, it makes more sense to return it instead of the emulated IOS device (which isn't really usable for any purpose other than emulated IPC).
-rw-r--r--Source/Core/Core/CMakeLists.txt1
-rw-r--r--Source/Core/Core/Core.vcxproj1
-rw-r--r--Source/Core/Core/Core.vcxproj.filters3
-rw-r--r--Source/Core/Core/IOS/FS/FileSystem.cpp15
-rw-r--r--Source/Core/Core/IOS/FS/FileSystem.h3
-rw-r--r--Source/Core/Core/IOS/IOS.cpp9
-rw-r--r--Source/Core/Core/IOS/IOS.h9
7 files changed, 37 insertions, 4 deletions
diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt
index f22d5ed3c9..d3e0cd5b97 100644
--- a/Source/Core/Core/CMakeLists.txt
+++ b/Source/Core/Core/CMakeLists.txt
@@ -165,6 +165,7 @@ add_library(core
IOS/ES/TitleInformation.cpp
IOS/ES/TitleManagement.cpp
IOS/ES/Views.cpp
+ IOS/FS/FileSystem.cpp
IOS/FS/HostBackend/File.cpp
IOS/FS/HostBackend/FS.cpp
IOS/FS/FileIO.cpp
diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj
index 847086a188..0abe26aa84 100644
--- a/Source/Core/Core/Core.vcxproj
+++ b/Source/Core/Core/Core.vcxproj
@@ -197,6 +197,7 @@
<ClCompile Include="IOS\ES\Views.cpp" />
<ClCompile Include="IOS\FS\FileIO.cpp" />
<ClCompile Include="IOS\FS\FS.cpp" />
+ <ClCompile Include="IOS\FS\FileSystem.cpp" />
<ClCompile Include="IOS\FS\HostBackend\FS.cpp" />
<ClCompile Include="IOS\FS\HostBackend\File.cpp" />
<ClCompile Include="IOS\Network\ICMPLin.cpp" />
diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters
index f997b6a741..cff27f6add 100644
--- a/Source/Core/Core/Core.vcxproj.filters
+++ b/Source/Core/Core/Core.vcxproj.filters
@@ -735,6 +735,9 @@
<ClCompile Include="IOS\FS\FileIO.cpp">
<Filter>IOS\FS</Filter>
</ClCompile>
+ <ClCompile Include="IOS\FS\FileSystem.cpp">
+ <Filter>IOS\FS</Filter>
+ </ClCompile>
<ClCompile Include="IOS\FS\HostBackend\FS.cpp">
<Filter>IOS\FS</Filter>
</ClCompile>
diff --git a/Source/Core/Core/IOS/FS/FileSystem.cpp b/Source/Core/Core/IOS/FS/FileSystem.cpp
new file mode 100644
index 0000000000..74cee8e9cd
--- /dev/null
+++ b/Source/Core/Core/IOS/FS/FileSystem.cpp
@@ -0,0 +1,15 @@
+// Copyright 2018 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include "Core/IOS/FS/FileSystem.h"
+
+#include "Core/IOS/FS/HostBackend/FS.h"
+
+namespace IOS::HLE::FS
+{
+std::unique_ptr<FileSystem> MakeFileSystem()
+{
+ return std::make_unique<HostFileSystem>();
+}
+} // namespace IOS::HLE::FS
diff --git a/Source/Core/Core/IOS/FS/FileSystem.h b/Source/Core/Core/IOS/FS/FileSystem.h
index 6607c9ab02..f56df41998 100644
--- a/Source/Core/Core/IOS/FS/FileSystem.h
+++ b/Source/Core/Core/IOS/FS/FileSystem.h
@@ -4,6 +4,7 @@
#pragma once
+#include <memory>
#include <string>
#include <vector>
@@ -170,4 +171,6 @@ public:
virtual Result<DirectoryStats> GetDirectoryStats(const std::string& path) = 0;
};
+std::unique_ptr<FileSystem> MakeFileSystem();
+
} // namespace IOS::HLE::FS
diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp
index 4abd2312a5..bd704fc895 100644
--- a/Source/Core/Core/IOS/IOS.cpp
+++ b/Source/Core/Core/IOS/IOS.cpp
@@ -33,6 +33,7 @@
#include "Core/IOS/ES/ES.h"
#include "Core/IOS/FS/FS.h"
#include "Core/IOS/FS/FileIO.h"
+#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/MIOS.h"
#include "Core/IOS/Network/IP/Top.h"
#include "Core/IOS/Network/KD/NetKDRequest.h"
@@ -242,9 +243,9 @@ u32 Kernel::GetVersion() const
return static_cast<u32>(m_title_id);
}
-std::shared_ptr<Device::FS> Kernel::GetFS()
+std::shared_ptr<FS::FileSystem> Kernel::GetFS()
{
- return std::static_pointer_cast<Device::FS>(m_device_map.at("/dev/fs"));
+ return m_fs;
}
std::shared_ptr<Device::ES> Kernel::GetES()
@@ -368,6 +369,9 @@ void Kernel::AddDevice(std::unique_ptr<Device::Device> device)
void Kernel::AddCoreDevices()
{
+ m_fs = FS::MakeFileSystem();
+ ASSERT(m_fs);
+
std::lock_guard<std::mutex> lock(m_device_map_mutex);
AddDevice(std::make_unique<Device::FS>(*this, "/dev/fs"));
AddDevice(std::make_unique<Device::ES>(*this, "/dev/es"));
@@ -691,6 +695,7 @@ void Kernel::DoState(PointerWrap& p)
p.Do(m_ppc_gid);
m_iosc.DoState(p);
+ m_fs->DoState(p);
if (m_title_id == Titles::MIOS)
return;
diff --git a/Source/Core/Core/IOS/IOS.h b/Source/Core/Core/IOS/IOS.h
index 0f58359683..1d3e94b50b 100644
--- a/Source/Core/Core/IOS/IOS.h
+++ b/Source/Core/Core/IOS/IOS.h
@@ -23,11 +23,15 @@ namespace IOS
{
namespace HLE
{
+namespace FS
+{
+class FileSystem;
+}
+
namespace Device
{
class Device;
class ES;
-class FS;
}
struct Request;
@@ -94,7 +98,7 @@ public:
// These are *always* part of the IOS kernel and always available.
// They are also the only available resource managers even before loading any module.
- std::shared_ptr<Device::FS> GetFS();
+ std::shared_ptr<FS::FileSystem> GetFS();
std::shared_ptr<Device::ES> GetES();
void SDIO_EventNotify();
@@ -146,6 +150,7 @@ protected:
u64 m_last_reply_time = 0;
IOSC m_iosc;
+ std::shared_ptr<FS::FileSystem> m_fs;
};
// HLE for an IOS tied to emulation: base kernel which may have additional modules loaded.