Skip to content

Commit e80c653

Browse files
author
N3xoX1
committed
Add RomFsController::OpenRomFSCurrentProcess
1 parent 3615b02 commit e80c653

9 files changed

Lines changed: 63 additions & 2 deletions

File tree

src/nxemu-loader/core/file_sys/romfs_factory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ RomFSFactoryPtr::~RomFSFactoryPtr()
7474
{
7575
}
7676

77+
IVirtualFile * RomFSFactoryPtr::OpenCurrentProcess(uint64_t currentProcessTitleId) const
78+
{
79+
UNIMPLEMENTED();
80+
return nullptr;
81+
}
82+
7783
void RomFSFactoryPtr::Release()
7884
{
7985
delete this;

src/nxemu-loader/core/file_sys/romfs_factory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class RomFSFactoryPtr :
7979
operator bool() const;
8080

8181
// IRomFsController
82+
IVirtualFile * OpenCurrentProcess(uint64_t currentProcessTitleId) const;
8283
void Release() override;
8384

8485
private:

src/nxemu-module-spec/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
enum
1818
{
19-
MODULE_LOADER_SPECS_VERSION = 0x0102,
19+
MODULE_LOADER_SPECS_VERSION = 0x0103,
2020
MODULE_VIDEO_SPECS_VERSION = 0x0101,
2121
MODULE_CPU_SPECS_VERSION = 0x0101,
2222
MODULE_OPERATING_SYSTEM_SPECS_VERSION = 0x0103,

src/nxemu-module-spec/system_loader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ __interface ISaveDataFactory
4747

4848
__interface IRomFsController
4949
{
50+
IVirtualFile * OpenCurrentProcess(uint64_t currentProcessTitleId) const = 0;
5051
void Release();
5152
};
5253

src/nxemu-os/core/file_sys/filesystem_interfaces.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,22 @@ IVirtualDirectoryPtr::operator bool() const
6969
return m_directory != nullptr;
7070
}
7171

72+
IVirtualFilePtr::IVirtualFilePtr() :
73+
m_file(nullptr)
74+
{
75+
}
76+
7277
IVirtualFilePtr::IVirtualFilePtr(IVirtualFile * file) :
7378
m_file(file)
7479
{
7580
}
7681

82+
IVirtualFilePtr::IVirtualFilePtr(IVirtualFilePtr && other) noexcept
83+
{
84+
m_file = other.m_file;
85+
other.m_file = nullptr;
86+
}
87+
7788
IVirtualFilePtr::~IVirtualFilePtr()
7889
{
7990
if (m_file != nullptr)
@@ -83,6 +94,27 @@ IVirtualFilePtr::~IVirtualFilePtr()
8394
m_file = nullptr;
8495
}
8596

97+
IVirtualFilePtr & IVirtualFilePtr::operator=(IVirtualFile * ptr)
98+
{
99+
if (m_file != ptr && m_file != nullptr)
100+
{
101+
m_file->Release();
102+
}
103+
m_file = ptr;
104+
return *this;
105+
}
106+
107+
IVirtualFilePtr & IVirtualFilePtr::operator=(IVirtualFilePtr && other) noexcept
108+
{
109+
if (m_file != nullptr)
110+
{
111+
m_file->Release();
112+
}
113+
m_file = other.m_file;
114+
other.m_file = nullptr;
115+
return *this;
116+
}
117+
86118
IVirtualFile * IVirtualFilePtr::operator->() const
87119
{
88120
return m_file;
@@ -240,4 +272,9 @@ IRomFsController ** RomFsControllerPtr::GetAddressForSet()
240272
m_ptr = nullptr;
241273
}
242274
return &m_ptr;
243-
}
275+
}
276+
277+
IRomFsController * RomFsControllerPtr::operator->() const
278+
{
279+
return m_ptr;
280+
}

src/nxemu-os/core/hle/service/filesystem/fsp/fsp_srv.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ Result FSP_SRV::OpenSaveDataTransferProhibiter(
235235
}
236236

237237
Result FSP_SRV::OpenDataStorageByCurrentProcess(OutInterface<IStorage> out_interface) {
238+
LOG_DEBUG(Service_FS, "called");
239+
240+
if (!romfs) {
241+
auto current_romfs = romfs_controller->OpenRomFSCurrentProcess();
242+
UNIMPLEMENTED();
243+
}
244+
238245
UNIMPLEMENTED();
239246
R_SUCCEED();
240247
}

src/nxemu-os/core/hle/service/filesystem/fsp/fsp_srv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "core/hle/service/cmif_types.h"
88
#include "core/hle/service/filesystem/fsp/fsp_types.h"
99
#include "core/hle/service/service.h"
10+
#include "core/file_sys/filesystem_interfaces.h"
1011

1112
namespace Core {
1213
class Reporter;
@@ -76,6 +77,7 @@ class FSP_SRV final : public ServiceFramework<FSP_SRV> {
7677
Result GetCacheStorageSize(s32 index, Out<s64> out_data_size, Out<s64> out_journal_size);
7778

7879
IFileSystemController & fsc;
80+
IVirtualFilePtr romfs;
7981
u64 current_process_id = 0;
8082
u32 access_log_program_index = 0;
8183
AccessLogMode access_log_mode = AccessLogMode::None;

src/nxemu-os/core/hle/service/filesystem/romfs_controller.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: GPL-2.0-or-later
33

44
#include "core/hle/service/filesystem/romfs_controller.h"
5+
#include <nxemu-module-spec/system_loader.h>
56

67
namespace Service::FileSystem {
78

@@ -15,4 +16,8 @@ RomFsController::~RomFsController()
1516
{
1617
}
1718

19+
IVirtualFilePtr RomFsController::OpenRomFSCurrentProcess() {
20+
return factory->OpenCurrentProcess(program_id);
21+
}
22+
1823
} // namespace Service::FileSystem

src/nxemu-os/core/hle/service/filesystem/romfs_controller.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class RomFsController {
1111
explicit RomFsController(RomFsControllerPtr && factory_, uint64_t program_id_);
1212
~RomFsController();
1313

14+
IVirtualFilePtr OpenRomFSCurrentProcess();
15+
1416
private:
1517
const RomFsControllerPtr factory;
1618
const uint64_t program_id;

0 commit comments

Comments
 (0)