summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-03-12 18:18:22 +0100
committerLéo Lam <leo@innovatetechnologi.es>2018-03-31 10:58:49 +0200
commit4e547772da89bc541352ae7376c369eb8ceb7f44 (patch)
treec39d3421148bafe75be64dafb3554f1b7e175e7b /Source/Core
parentc56f31906ceabf8a708d5c81f03bfced1e4b7669 (diff)
IOS/FS: Make the NAND root path a parameter
Cleaner than having the backend figure out which NAND root to use.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/IOS/FS/FileSystem.cpp7
-rw-r--r--Source/Core/Core/IOS/FS/FileSystem.h8
-rw-r--r--Source/Core/Core/IOS/FS/HostBackend/FS.cpp11
-rw-r--r--Source/Core/Core/IOS/FS/HostBackend/FS.h5
4 files changed, 21 insertions, 10 deletions
diff --git a/Source/Core/Core/IOS/FS/FileSystem.cpp b/Source/Core/Core/IOS/FS/FileSystem.cpp
index f3910c3374..552d68ec8b 100644
--- a/Source/Core/Core/IOS/FS/FileSystem.cpp
+++ b/Source/Core/Core/IOS/FS/FileSystem.cpp
@@ -5,13 +5,16 @@
#include "Core/IOS/FS/FileSystem.h"
#include "Common/Assert.h"
+#include "Common/FileUtil.h"
#include "Core/IOS/FS/HostBackend/FS.h"
namespace IOS::HLE::FS
{
-std::unique_ptr<FileSystem> MakeFileSystem()
+std::unique_ptr<FileSystem> MakeFileSystem(Location location)
{
- return std::make_unique<HostFileSystem>();
+ const std::string nand_root =
+ File::GetUserPath(location == Location::Session ? D_SESSION_WIIROOT_IDX : D_WIIROOT_IDX);
+ return std::make_unique<HostFileSystem>(nand_root);
}
FileHandle::FileHandle(FileSystem* fs, Fd fd) : m_fs{fs}, m_fd{fd}
diff --git a/Source/Core/Core/IOS/FS/FileSystem.h b/Source/Core/Core/IOS/FS/FileSystem.h
index 25894a60b0..87890cdbad 100644
--- a/Source/Core/Core/IOS/FS/FileSystem.h
+++ b/Source/Core/Core/IOS/FS/FileSystem.h
@@ -195,6 +195,12 @@ protected:
void Init();
};
-std::unique_ptr<FileSystem> MakeFileSystem();
+enum class Location
+{
+ Configured,
+ Session,
+};
+
+std::unique_ptr<FileSystem> MakeFileSystem(Location location = Location::Session);
} // namespace IOS::HLE::FS
diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp
index 4e18e0ac34..1e512a623a 100644
--- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp
+++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp
@@ -20,14 +20,13 @@ static bool IsValidWiiPath(const std::string& path)
return path.compare(0, 1, "/") == 0;
}
-std::string HostFileSystem::BuildFilename(const std::string& wii_path)
+std::string HostFileSystem::BuildFilename(const std::string& wii_path) const
{
- std::string nand_path = File::GetUserPath(D_SESSION_WIIROOT_IDX);
if (wii_path.compare(0, 1, "/") == 0)
- return nand_path + Common::EscapePath(wii_path);
+ return m_root_path + Common::EscapePath(wii_path);
ASSERT(false);
- return nand_path;
+ return m_root_path;
}
// Get total filesize of contents of a directory (recursive)
@@ -45,7 +44,7 @@ static u64 ComputeTotalFileSize(const File::FSTEntry& parent_entry)
return sizeOfFiles;
}
-HostFileSystem::HostFileSystem()
+HostFileSystem::HostFileSystem(const std::string& root_path) : m_root_path{root_path}
{
Init();
}
@@ -54,6 +53,8 @@ HostFileSystem::~HostFileSystem() = default;
void HostFileSystem::DoState(PointerWrap& p)
{
+ p.Do(m_root_path);
+
// Temporarily close the file, to prevent any issues with the savestating of /tmp
for (Handle& handle : m_handles)
handle.host_file.reset();
diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.h b/Source/Core/Core/IOS/FS/HostBackend/FS.h
index 60f5d4dfd4..b30e1742f6 100644
--- a/Source/Core/Core/IOS/FS/HostBackend/FS.h
+++ b/Source/Core/Core/IOS/FS/HostBackend/FS.h
@@ -23,7 +23,7 @@ namespace IOS::HLE::FS
class HostFileSystem final : public FileSystem
{
public:
- HostFileSystem();
+ HostFileSystem(const std::string& root_path);
~HostFileSystem();
void DoState(PointerWrap& p) override;
@@ -73,9 +73,10 @@ private:
Handle* GetHandleFromFd(Fd fd);
Fd ConvertHandleToFd(const Handle* handle) const;
- std::string BuildFilename(const std::string& wii_path);
+ std::string BuildFilename(const std::string& wii_path) const;
std::shared_ptr<File::IOFile> OpenHostFile(const std::string& host_path);
+ std::string m_root_path;
std::array<Handle, 16> m_handles{};
std::map<std::string, std::weak_ptr<File::IOFile>> m_open_files;
};