summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_directory.cpp58
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_directory.h7
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_file.cpp74
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_file.h5
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp41
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_filesystem.h5
6 files changed, 65 insertions, 125 deletions
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp b/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp
index 39690018b..661da5326 100644
--- a/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp
+++ b/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp
@@ -8,43 +8,15 @@
8 8
9namespace Service::FileSystem { 9namespace Service::FileSystem {
10 10
11template <typename T> 11IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir directory_,
12static void BuildEntryIndex(std::vector<FileSys::DirectoryEntry>& entries,
13 const std::vector<T>& new_data, FileSys::DirectoryEntryType type) {
14 entries.reserve(entries.size() + new_data.size());
15
16 for (const auto& new_entry : new_data) {
17 auto name = new_entry->GetName();
18
19 if (type == FileSys::DirectoryEntryType::File &&
20 name == FileSys::GetSaveDataSizeFileName()) {
21 continue;
22 }
23
24 entries.emplace_back(name, static_cast<s8>(type),
25 type == FileSys::DirectoryEntryType::Directory ? 0
26 : new_entry->GetSize());
27 }
28}
29
30IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir backend_,
31 FileSys::OpenDirectoryMode mode) 12 FileSys::OpenDirectoryMode mode)
32 : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) { 13 : ServiceFramework{system_, "IDirectory"},
14 backend(std::make_unique<FileSys::Fsa::IDirectory>(directory_, mode)) {
33 static const FunctionInfo functions[] = { 15 static const FunctionInfo functions[] = {
34 {0, &IDirectory::Read, "Read"}, 16 {0, &IDirectory::Read, "Read"},
35 {1, &IDirectory::GetEntryCount, "GetEntryCount"}, 17 {1, &IDirectory::GetEntryCount, "GetEntryCount"},
36 }; 18 };
37 RegisterHandlers(functions); 19 RegisterHandlers(functions);
38
39 // TODO(DarkLordZach): Verify that this is the correct behavior.
40 // Build entry index now to save time later.
41 if (True(mode & FileSys::OpenDirectoryMode::Directory)) {
42 BuildEntryIndex(entries, backend->GetSubdirectories(),
43 FileSys::DirectoryEntryType::Directory);
44 }
45 if (True(mode & FileSys::OpenDirectoryMode::File)) {
46 BuildEntryIndex(entries, backend->GetFiles(), FileSys::DirectoryEntryType::File);
47 }
48} 20}
49 21
50void IDirectory::Read(HLERequestContext& ctx) { 22void IDirectory::Read(HLERequestContext& ctx) {
@@ -53,32 +25,26 @@ void IDirectory::Read(HLERequestContext& ctx) {
53 // Calculate how many entries we can fit in the output buffer 25 // Calculate how many entries we can fit in the output buffer
54 const u64 count_entries = ctx.GetWriteBufferNumElements<FileSys::DirectoryEntry>(); 26 const u64 count_entries = ctx.GetWriteBufferNumElements<FileSys::DirectoryEntry>();
55 27
56 // Cap at total number of entries. 28 s64 out_count{};
57 const u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index); 29 FileSys::DirectoryEntry* out_entries = nullptr;
58 30 const auto result = backend->Read(&out_count, out_entries, count_entries);
59 // Determine data start and end
60 const auto* begin = reinterpret_cast<u8*>(entries.data() + next_entry_index);
61 const auto* end = reinterpret_cast<u8*>(entries.data() + next_entry_index + actual_entries);
62 const auto range_size = static_cast<std::size_t>(std::distance(begin, end));
63
64 next_entry_index += actual_entries;
65 31
66 // Write the data to memory 32 // Write the data to memory
67 ctx.WriteBuffer(begin, range_size); 33 ctx.WriteBuffer(out_entries, out_count);
68 34
69 IPC::ResponseBuilder rb{ctx, 4}; 35 IPC::ResponseBuilder rb{ctx, 4};
70 rb.Push(ResultSuccess); 36 rb.Push(result);
71 rb.Push(actual_entries); 37 rb.Push(out_count);
72} 38}
73 39
74void IDirectory::GetEntryCount(HLERequestContext& ctx) { 40void IDirectory::GetEntryCount(HLERequestContext& ctx) {
75 LOG_DEBUG(Service_FS, "called"); 41 LOG_DEBUG(Service_FS, "called");
76 42
77 u64 count = entries.size() - next_entry_index; 43 s64 out_count{};
78 44
79 IPC::ResponseBuilder rb{ctx, 4}; 45 IPC::ResponseBuilder rb{ctx, 4};
80 rb.Push(ResultSuccess); 46 rb.Push(backend->GetEntryCount(&out_count));
81 rb.Push(count); 47 rb.Push(out_count);
82} 48}
83 49
84} // namespace Service::FileSystem 50} // namespace Service::FileSystem
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_directory.h b/src/core/hle/service/filesystem/fsp/fs_i_directory.h
index 793ecfcd7..0dec4367b 100644
--- a/src/core/hle/service/filesystem/fsp/fs_i_directory.h
+++ b/src/core/hle/service/filesystem/fsp/fs_i_directory.h
@@ -3,6 +3,7 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "core/file_sys/fsa/fs_i_directory.h"
6#include "core/file_sys/vfs/vfs.h" 7#include "core/file_sys/vfs/vfs.h"
7#include "core/hle/service/filesystem/filesystem.h" 8#include "core/hle/service/filesystem/filesystem.h"
8#include "core/hle/service/service.h" 9#include "core/hle/service/service.h"
@@ -15,13 +16,11 @@ namespace Service::FileSystem {
15 16
16class IDirectory final : public ServiceFramework<IDirectory> { 17class IDirectory final : public ServiceFramework<IDirectory> {
17public: 18public:
18 explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_, 19 explicit IDirectory(Core::System& system_, FileSys::VirtualDir directory_,
19 FileSys::OpenDirectoryMode mode); 20 FileSys::OpenDirectoryMode mode);
20 21
21private: 22private:
22 FileSys::VirtualDir backend; 23 std::unique_ptr<FileSys::Fsa::IDirectory> backend;
23 std::vector<FileSys::DirectoryEntry> entries;
24 u64 next_entry_index = 0;
25 24
26 void Read(HLERequestContext& ctx); 25 void Read(HLERequestContext& ctx);
27 void GetEntryCount(HLERequestContext& ctx); 26 void GetEntryCount(HLERequestContext& ctx);
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_file.cpp b/src/core/hle/service/filesystem/fsp/fs_i_file.cpp
index 9a18f6ec5..8fb8620de 100644
--- a/src/core/hle/service/filesystem/fsp/fs_i_file.cpp
+++ b/src/core/hle/service/filesystem/fsp/fs_i_file.cpp
@@ -7,8 +7,8 @@
7 7
8namespace Service::FileSystem { 8namespace Service::FileSystem {
9 9
10IFile::IFile(Core::System& system_, FileSys::VirtualFile backend_) 10IFile::IFile(Core::System& system_, FileSys::VirtualFile file_)
11 : ServiceFramework{system_, "IFile"}, backend(std::move(backend_)) { 11 : ServiceFramework{system_, "IFile"}, backend{std::make_unique<FileSys::Fsa::IFile>(file_)} {
12 static const FunctionInfo functions[] = { 12 static const FunctionInfo functions[] = {
13 {0, &IFile::Read, "Read"}, 13 {0, &IFile::Read, "Read"},
14 {1, &IFile::Write, "Write"}, 14 {1, &IFile::Write, "Write"},
@@ -29,79 +29,40 @@ void IFile::Read(HLERequestContext& ctx) {
29 29
30 LOG_DEBUG(Service_FS, "called, option={}, offset=0x{:X}, length={}", option, offset, length); 30 LOG_DEBUG(Service_FS, "called, option={}, offset=0x{:X}, length={}", option, offset, length);
31 31
32 // Error checking
33 if (length < 0) {
34 LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
35 IPC::ResponseBuilder rb{ctx, 2};
36 rb.Push(FileSys::ResultInvalidSize);
37 return;
38 }
39 if (offset < 0) {
40 LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
41 IPC::ResponseBuilder rb{ctx, 2};
42 rb.Push(FileSys::ResultInvalidOffset);
43 return;
44 }
45
46 // Read the data from the Storage backend 32 // Read the data from the Storage backend
47 std::vector<u8> output = backend->ReadBytes(length, offset); 33 std::vector<u8> output(length);
34 std::size_t bytes_read;
35 const auto result = backend->Read(&bytes_read, offset, output.data(), length);
48 36
49 // Write the data to memory 37 // Write the data to memory
50 ctx.WriteBuffer(output); 38 ctx.WriteBuffer(output);
51 39
52 IPC::ResponseBuilder rb{ctx, 4}; 40 IPC::ResponseBuilder rb{ctx, 4};
53 rb.Push(ResultSuccess); 41 rb.Push(result);
54 rb.Push(static_cast<u64>(output.size())); 42 rb.Push(static_cast<u64>(bytes_read));
55} 43}
56 44
57void IFile::Write(HLERequestContext& ctx) { 45void IFile::Write(HLERequestContext& ctx) {
58 IPC::RequestParser rp{ctx}; 46 IPC::RequestParser rp{ctx};
59 const u64 option = rp.Pop<u64>(); 47 const auto option = rp.PopRaw<FileSys::WriteOption>();
48 [[maybe_unused]] const u32 unused = rp.Pop<u32>();
60 const s64 offset = rp.Pop<s64>(); 49 const s64 offset = rp.Pop<s64>();
61 const s64 length = rp.Pop<s64>(); 50 const s64 length = rp.Pop<s64>();
62 51
63 LOG_DEBUG(Service_FS, "called, option={}, offset=0x{:X}, length={}", option, offset, length); 52 LOG_DEBUG(Service_FS, "called, option={}, offset=0x{:X}, length={}", option.value, offset,
64 53 length);
65 // Error checking
66 if (length < 0) {
67 LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
68 IPC::ResponseBuilder rb{ctx, 2};
69 rb.Push(FileSys::ResultInvalidSize);
70 return;
71 }
72 if (offset < 0) {
73 LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
74 IPC::ResponseBuilder rb{ctx, 2};
75 rb.Push(FileSys::ResultInvalidOffset);
76 return;
77 }
78 54
79 const auto data = ctx.ReadBuffer(); 55 const auto data = ctx.ReadBuffer();
80 56
81 ASSERT_MSG(static_cast<s64>(data.size()) <= length,
82 "Attempting to write more data than requested (requested={:016X}, actual={:016X}).",
83 length, data.size());
84
85 // Write the data to the Storage backend
86 const auto write_size =
87 static_cast<std::size_t>(std::distance(data.begin(), data.begin() + length));
88 const std::size_t written = backend->Write(data.data(), write_size, offset);
89
90 ASSERT_MSG(static_cast<s64>(written) == length,
91 "Could not write all bytes to file (requested={:016X}, actual={:016X}).", length,
92 written);
93
94 IPC::ResponseBuilder rb{ctx, 2}; 57 IPC::ResponseBuilder rb{ctx, 2};
95 rb.Push(ResultSuccess); 58 rb.Push(backend->Write(offset, data.data(), length, option));
96} 59}
97 60
98void IFile::Flush(HLERequestContext& ctx) { 61void IFile::Flush(HLERequestContext& ctx) {
99 LOG_DEBUG(Service_FS, "called"); 62 LOG_DEBUG(Service_FS, "called");
100 63
101 // Exists for SDK compatibiltity -- No need to flush file.
102
103 IPC::ResponseBuilder rb{ctx, 2}; 64 IPC::ResponseBuilder rb{ctx, 2};
104 rb.Push(ResultSuccess); 65 rb.Push(backend->Flush());
105} 66}
106 67
107void IFile::SetSize(HLERequestContext& ctx) { 68void IFile::SetSize(HLERequestContext& ctx) {
@@ -109,18 +70,17 @@ void IFile::SetSize(HLERequestContext& ctx) {
109 const u64 size = rp.Pop<u64>(); 70 const u64 size = rp.Pop<u64>();
110 LOG_DEBUG(Service_FS, "called, size={}", size); 71 LOG_DEBUG(Service_FS, "called, size={}", size);
111 72
112 backend->Resize(size);
113
114 IPC::ResponseBuilder rb{ctx, 2}; 73 IPC::ResponseBuilder rb{ctx, 2};
115 rb.Push(ResultSuccess); 74 rb.Push(backend->SetSize(size));
116} 75}
117 76
118void IFile::GetSize(HLERequestContext& ctx) { 77void IFile::GetSize(HLERequestContext& ctx) {
119 const u64 size = backend->GetSize(); 78 s64 size;
79 const auto result = backend->GetSize(&size);
120 LOG_DEBUG(Service_FS, "called, size={}", size); 80 LOG_DEBUG(Service_FS, "called, size={}", size);
121 81
122 IPC::ResponseBuilder rb{ctx, 4}; 82 IPC::ResponseBuilder rb{ctx, 4};
123 rb.Push(ResultSuccess); 83 rb.Push(result);
124 rb.Push<u64>(size); 84 rb.Push<u64>(size);
125} 85}
126 86
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_file.h b/src/core/hle/service/filesystem/fsp/fs_i_file.h
index 5e5430c67..887fd3ba2 100644
--- a/src/core/hle/service/filesystem/fsp/fs_i_file.h
+++ b/src/core/hle/service/filesystem/fsp/fs_i_file.h
@@ -3,6 +3,7 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "core/file_sys/fsa/fs_i_file.h"
6#include "core/hle/service/filesystem/filesystem.h" 7#include "core/hle/service/filesystem/filesystem.h"
7#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
8 9
@@ -10,10 +11,10 @@ namespace Service::FileSystem {
10 11
11class IFile final : public ServiceFramework<IFile> { 12class IFile final : public ServiceFramework<IFile> {
12public: 13public:
13 explicit IFile(Core::System& system_, FileSys::VirtualFile backend_); 14 explicit IFile(Core::System& system_, FileSys::VirtualFile file_);
14 15
15private: 16private:
16 FileSys::VirtualFile backend; 17 std::unique_ptr<FileSys::Fsa::IFile> backend;
17 18
18 void Read(HLERequestContext& ctx); 19 void Read(HLERequestContext& ctx);
19 void Write(HLERequestContext& ctx); 20 void Write(HLERequestContext& ctx);
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp
index efa394dd1..1e69d22b8 100644
--- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp
+++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp
@@ -9,9 +9,9 @@
9 9
10namespace Service::FileSystem { 10namespace Service::FileSystem {
11 11
12IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_) 12IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGetter size_)
13 : ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, size{std::move( 13 : ServiceFramework{system_, "IFileSystem"},
14 size_)} { 14 backend{std::make_unique<FileSys::Fsa::IFileSystem>(dir_)}, size{std::move(size_)} {
15 static const FunctionInfo functions[] = { 15 static const FunctionInfo functions[] = {
16 {0, &IFileSystem::CreateFile, "CreateFile"}, 16 {0, &IFileSystem::CreateFile, "CreateFile"},
17 {1, &IFileSystem::DeleteFile, "DeleteFile"}, 17 {1, &IFileSystem::DeleteFile, "DeleteFile"},
@@ -39,6 +39,7 @@ void IFileSystem::CreateFile(HLERequestContext& ctx) {
39 39
40 const auto file_buffer = ctx.ReadBuffer(); 40 const auto file_buffer = ctx.ReadBuffer();
41 const std::string name = Common::StringFromBuffer(file_buffer); 41 const std::string name = Common::StringFromBuffer(file_buffer);
42 const auto path = FileSys::Path(name.c_str());
42 43
43 const u64 file_mode = rp.Pop<u64>(); 44 const u64 file_mode = rp.Pop<u64>();
44 const u32 file_size = rp.Pop<u32>(); 45 const u32 file_size = rp.Pop<u32>();
@@ -47,67 +48,75 @@ void IFileSystem::CreateFile(HLERequestContext& ctx) {
47 file_size); 48 file_size);
48 49
49 IPC::ResponseBuilder rb{ctx, 2}; 50 IPC::ResponseBuilder rb{ctx, 2};
50 rb.Push(backend.CreateFile(name, file_size)); 51 rb.Push(backend->CreateFile(path, file_size));
51} 52}
52 53
53void IFileSystem::DeleteFile(HLERequestContext& ctx) { 54void IFileSystem::DeleteFile(HLERequestContext& ctx) {
54 const auto file_buffer = ctx.ReadBuffer(); 55 const auto file_buffer = ctx.ReadBuffer();
55 const std::string name = Common::StringFromBuffer(file_buffer); 56 const std::string name = Common::StringFromBuffer(file_buffer);
57 const auto path = FileSys::Path(name.c_str());
56 58
57 LOG_DEBUG(Service_FS, "called. file={}", name); 59 LOG_DEBUG(Service_FS, "called. file={}", name);
58 60
59 IPC::ResponseBuilder rb{ctx, 2}; 61 IPC::ResponseBuilder rb{ctx, 2};
60 rb.Push(backend.DeleteFile(name)); 62 rb.Push(backend->DeleteFile(path));
61} 63}
62 64
63void IFileSystem::CreateDirectory(HLERequestContext& ctx) { 65void IFileSystem::CreateDirectory(HLERequestContext& ctx) {
64 const auto file_buffer = ctx.ReadBuffer(); 66 const auto file_buffer = ctx.ReadBuffer();
65 const std::string name = Common::StringFromBuffer(file_buffer); 67 const std::string name = Common::StringFromBuffer(file_buffer);
68 const auto path = FileSys::Path(name.c_str());
66 69
67 LOG_DEBUG(Service_FS, "called. directory={}", name); 70 LOG_DEBUG(Service_FS, "called. directory={}", name);
68 71
69 IPC::ResponseBuilder rb{ctx, 2}; 72 IPC::ResponseBuilder rb{ctx, 2};
70 rb.Push(backend.CreateDirectory(name)); 73 rb.Push(backend->CreateDirectory(path));
71} 74}
72 75
73void IFileSystem::DeleteDirectory(HLERequestContext& ctx) { 76void IFileSystem::DeleteDirectory(HLERequestContext& ctx) {
74 const auto file_buffer = ctx.ReadBuffer(); 77 const auto file_buffer = ctx.ReadBuffer();
75 const std::string name = Common::StringFromBuffer(file_buffer); 78 const std::string name = Common::StringFromBuffer(file_buffer);
79 const auto path = FileSys::Path(name.c_str());
76 80
77 LOG_DEBUG(Service_FS, "called. directory={}", name); 81 LOG_DEBUG(Service_FS, "called. directory={}", name);
78 82
79 IPC::ResponseBuilder rb{ctx, 2}; 83 IPC::ResponseBuilder rb{ctx, 2};
80 rb.Push(backend.DeleteDirectory(name)); 84 rb.Push(backend->DeleteDirectory(path));
81} 85}
82 86
83void IFileSystem::DeleteDirectoryRecursively(HLERequestContext& ctx) { 87void IFileSystem::DeleteDirectoryRecursively(HLERequestContext& ctx) {
84 const auto file_buffer = ctx.ReadBuffer(); 88 const auto file_buffer = ctx.ReadBuffer();
85 const std::string name = Common::StringFromBuffer(file_buffer); 89 const std::string name = Common::StringFromBuffer(file_buffer);
90 const auto path = FileSys::Path(name.c_str());
86 91
87 LOG_DEBUG(Service_FS, "called. directory={}", name); 92 LOG_DEBUG(Service_FS, "called. directory={}", name);
88 93
89 IPC::ResponseBuilder rb{ctx, 2}; 94 IPC::ResponseBuilder rb{ctx, 2};
90 rb.Push(backend.DeleteDirectoryRecursively(name)); 95 rb.Push(backend->DeleteDirectoryRecursively(path));
91} 96}
92 97
93void IFileSystem::CleanDirectoryRecursively(HLERequestContext& ctx) { 98void IFileSystem::CleanDirectoryRecursively(HLERequestContext& ctx) {
94 const auto file_buffer = ctx.ReadBuffer(); 99 const auto file_buffer = ctx.ReadBuffer();
95 const std::string name = Common::StringFromBuffer(file_buffer); 100 const std::string name = Common::StringFromBuffer(file_buffer);
101 const auto path = FileSys::Path(name.c_str());
96 102
97 LOG_DEBUG(Service_FS, "called. Directory: {}", name); 103 LOG_DEBUG(Service_FS, "called. Directory: {}", name);
98 104
99 IPC::ResponseBuilder rb{ctx, 2}; 105 IPC::ResponseBuilder rb{ctx, 2};
100 rb.Push(backend.CleanDirectoryRecursively(name)); 106 rb.Push(backend->CleanDirectoryRecursively(path));
101} 107}
102 108
103void IFileSystem::RenameFile(HLERequestContext& ctx) { 109void IFileSystem::RenameFile(HLERequestContext& ctx) {
104 const std::string src_name = Common::StringFromBuffer(ctx.ReadBuffer(0)); 110 const std::string src_name = Common::StringFromBuffer(ctx.ReadBuffer(0));
105 const std::string dst_name = Common::StringFromBuffer(ctx.ReadBuffer(1)); 111 const std::string dst_name = Common::StringFromBuffer(ctx.ReadBuffer(1));
106 112
113 const auto src_path = FileSys::Path(src_name.c_str());
114 const auto dst_path = FileSys::Path(dst_name.c_str());
115
107 LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name); 116 LOG_DEBUG(Service_FS, "called. file '{}' to file '{}'", src_name, dst_name);
108 117
109 IPC::ResponseBuilder rb{ctx, 2}; 118 IPC::ResponseBuilder rb{ctx, 2};
110 rb.Push(backend.RenameFile(src_name, dst_name)); 119 rb.Push(backend->RenameFile(src_path, dst_path));
111} 120}
112 121
113void IFileSystem::OpenFile(HLERequestContext& ctx) { 122void IFileSystem::OpenFile(HLERequestContext& ctx) {
@@ -115,13 +124,14 @@ void IFileSystem::OpenFile(HLERequestContext& ctx) {
115 124
116 const auto file_buffer = ctx.ReadBuffer(); 125 const auto file_buffer = ctx.ReadBuffer();
117 const std::string name = Common::StringFromBuffer(file_buffer); 126 const std::string name = Common::StringFromBuffer(file_buffer);
127 const auto path = FileSys::Path(name.c_str());
118 128
119 const auto mode = static_cast<FileSys::OpenMode>(rp.Pop<u32>()); 129 const auto mode = static_cast<FileSys::OpenMode>(rp.Pop<u32>());
120 130
121 LOG_DEBUG(Service_FS, "called. file={}, mode={}", name, mode); 131 LOG_DEBUG(Service_FS, "called. file={}, mode={}", name, mode);
122 132
123 FileSys::VirtualFile vfs_file{}; 133 FileSys::VirtualFile vfs_file{};
124 auto result = backend.OpenFile(&vfs_file, name, mode); 134 auto result = backend->OpenFile(&vfs_file, path, mode);
125 if (result != ResultSuccess) { 135 if (result != ResultSuccess) {
126 IPC::ResponseBuilder rb{ctx, 2}; 136 IPC::ResponseBuilder rb{ctx, 2};
127 rb.Push(result); 137 rb.Push(result);
@@ -140,12 +150,13 @@ void IFileSystem::OpenDirectory(HLERequestContext& ctx) {
140 150
141 const auto file_buffer = ctx.ReadBuffer(); 151 const auto file_buffer = ctx.ReadBuffer();
142 const std::string name = Common::StringFromBuffer(file_buffer); 152 const std::string name = Common::StringFromBuffer(file_buffer);
153 const auto path = FileSys::Path(name.c_str());
143 const auto mode = rp.PopRaw<FileSys::OpenDirectoryMode>(); 154 const auto mode = rp.PopRaw<FileSys::OpenDirectoryMode>();
144 155
145 LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode); 156 LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode);
146 157
147 FileSys::VirtualDir vfs_dir{}; 158 FileSys::VirtualDir vfs_dir{};
148 auto result = backend.OpenDirectory(&vfs_dir, name); 159 auto result = backend->OpenDirectory(&vfs_dir, path, mode);
149 if (result != ResultSuccess) { 160 if (result != ResultSuccess) {
150 IPC::ResponseBuilder rb{ctx, 2}; 161 IPC::ResponseBuilder rb{ctx, 2};
151 rb.Push(result); 162 rb.Push(result);
@@ -162,11 +173,12 @@ void IFileSystem::OpenDirectory(HLERequestContext& ctx) {
162void IFileSystem::GetEntryType(HLERequestContext& ctx) { 173void IFileSystem::GetEntryType(HLERequestContext& ctx) {
163 const auto file_buffer = ctx.ReadBuffer(); 174 const auto file_buffer = ctx.ReadBuffer();
164 const std::string name = Common::StringFromBuffer(file_buffer); 175 const std::string name = Common::StringFromBuffer(file_buffer);
176 const auto path = FileSys::Path(name.c_str());
165 177
166 LOG_DEBUG(Service_FS, "called. file={}", name); 178 LOG_DEBUG(Service_FS, "called. file={}", name);
167 179
168 FileSys::DirectoryEntryType vfs_entry_type{}; 180 FileSys::DirectoryEntryType vfs_entry_type{};
169 auto result = backend.GetEntryType(&vfs_entry_type, name); 181 auto result = backend->GetEntryType(&vfs_entry_type, path);
170 if (result != ResultSuccess) { 182 if (result != ResultSuccess) {
171 IPC::ResponseBuilder rb{ctx, 2}; 183 IPC::ResponseBuilder rb{ctx, 2};
172 rb.Push(result); 184 rb.Push(result);
@@ -204,11 +216,12 @@ void IFileSystem::GetTotalSpaceSize(HLERequestContext& ctx) {
204void IFileSystem::GetFileTimeStampRaw(HLERequestContext& ctx) { 216void IFileSystem::GetFileTimeStampRaw(HLERequestContext& ctx) {
205 const auto file_buffer = ctx.ReadBuffer(); 217 const auto file_buffer = ctx.ReadBuffer();
206 const std::string name = Common::StringFromBuffer(file_buffer); 218 const std::string name = Common::StringFromBuffer(file_buffer);
219 const auto path = FileSys::Path(name.c_str());
207 220
208 LOG_WARNING(Service_FS, "(Partial Implementation) called. file={}", name); 221 LOG_WARNING(Service_FS, "(Partial Implementation) called. file={}", name);
209 222
210 FileSys::FileTimeStampRaw vfs_timestamp{}; 223 FileSys::FileTimeStampRaw vfs_timestamp{};
211 auto result = backend.GetFileTimeStampRaw(&vfs_timestamp, name); 224 auto result = backend->GetFileTimeStampRaw(&vfs_timestamp, path);
212 if (result != ResultSuccess) { 225 if (result != ResultSuccess) {
213 IPC::ResponseBuilder rb{ctx, 2}; 226 IPC::ResponseBuilder rb{ctx, 2};
214 rb.Push(result); 227 rb.Push(result);
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h
index b06b3ef0e..d500be725 100644
--- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h
+++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h
@@ -3,6 +3,7 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "core/file_sys/fsa/fs_i_filesystem.h"
6#include "core/file_sys/vfs/vfs.h" 7#include "core/file_sys/vfs/vfs.h"
7#include "core/hle/service/filesystem/filesystem.h" 8#include "core/hle/service/filesystem/filesystem.h"
8#include "core/hle/service/filesystem/fsp/fsp_util.h" 9#include "core/hle/service/filesystem/fsp/fsp_util.h"
@@ -12,7 +13,7 @@ namespace Service::FileSystem {
12 13
13class IFileSystem final : public ServiceFramework<IFileSystem> { 14class IFileSystem final : public ServiceFramework<IFileSystem> {
14public: 15public:
15 explicit IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_); 16 explicit IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGetter size_);
16 17
17 void CreateFile(HLERequestContext& ctx); 18 void CreateFile(HLERequestContext& ctx);
18 void DeleteFile(HLERequestContext& ctx); 19 void DeleteFile(HLERequestContext& ctx);
@@ -31,7 +32,7 @@ public:
31 void GetFileSystemAttribute(HLERequestContext& ctx); 32 void GetFileSystemAttribute(HLERequestContext& ctx);
32 33
33private: 34private:
34 VfsDirectoryServiceWrapper backend; 35 std::unique_ptr<FileSys::Fsa::IFileSystem> backend;
35 SizeGetter size; 36 SizeGetter size;
36}; 37};
37 38