mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-07-24 23:47:10 +02:00
Ipc refactor (#9)
* Start refactoring IPC objects (started with IFile and IFileSystem) * End refactoring IPC objects (#8) * End refactoring IPC objects * End refactoring IPC objects corrections
This commit is contained in:
parent
7f4a190665
commit
322f28668d
62 changed files with 935 additions and 619 deletions
79
Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs
Normal file
79
Ryujinx/OsHle/Objects/FspSrv/IFileSystem.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
using ChocolArm64.Memory;
|
||||
using Ryujinx.OsHle.Ipc;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using static Ryujinx.OsHle.Objects.ObjHelper;
|
||||
|
||||
namespace Ryujinx.OsHle.Objects.FspSrv
|
||||
{
|
||||
class IFileSystem : IIpcInterface
|
||||
{
|
||||
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
||||
|
||||
public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private string Path;
|
||||
|
||||
public IFileSystem(string Path)
|
||||
{
|
||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||
{
|
||||
{ 7, GetEntryType },
|
||||
{ 8, OpenFile },
|
||||
{ 10, Commit }
|
||||
};
|
||||
|
||||
this.Path = Path;
|
||||
}
|
||||
|
||||
public long GetEntryType(ServiceCtx Context)
|
||||
{
|
||||
long Position = Context.Request.PtrBuff[0].Position;
|
||||
|
||||
string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position);
|
||||
|
||||
string FileName = Context.Ns.VFs.GetFullPath(Path, Name);
|
||||
|
||||
if (FileName == null)
|
||||
{
|
||||
//TODO: Correct error code.
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool IsFile = File.Exists(FileName);
|
||||
|
||||
Context.ResponseData.Write(IsFile ? 1 : 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long OpenFile(ServiceCtx Context)
|
||||
{
|
||||
long Position = Context.Request.PtrBuff[0].Position;
|
||||
|
||||
int FilterFlags = Context.RequestData.ReadInt32();
|
||||
|
||||
string Name = AMemoryHelper.ReadAsciiString(Context.Memory, Position);
|
||||
|
||||
string FileName = Context.Ns.VFs.GetFullPath(Path, Name);
|
||||
|
||||
if (FileName == null)
|
||||
{
|
||||
//TODO: Correct error code.
|
||||
return -1;
|
||||
}
|
||||
|
||||
FileStream Stream = new FileStream(FileName, FileMode.OpenOrCreate);
|
||||
|
||||
MakeObject(Context, new IFile(Stream));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long Commit(ServiceCtx Context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue