1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-27 04:12:02 +00:00

Implement IFileSystem:CleanDirectoryRecursively (#283)

* implement ifilesys:cleandirectoryrecursively

* clean up Ifilesystem
This commit is contained in:
emmauss 2018-07-18 22:05:17 +03:00 committed by Ac_K
parent 98223b0e7d
commit 2236f4b2c3

View file

@ -35,7 +35,7 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
{ 10, Commit },
{ 11, GetFreeSpaceSize },
{ 12, GetTotalSpaceSize },
//{ 13, CleanDirectoryRecursively },
{ 13, CleanDirectoryRecursively },
//{ 14, GetFileTimeStampRaw }
};
@ -46,8 +46,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long CreateFile(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context);
long Mode = Context.RequestData.ReadInt64();
@ -80,8 +78,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long DeleteFile(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context);
string FileName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -103,8 +99,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long CreateDirectory(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context);
string DirName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -141,8 +135,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
private long DeleteDirectory(ServiceCtx Context, bool Recursive)
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context);
string DirName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -220,8 +212,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long GetEntryType(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context);
string FileName = Context.Ns.VFs.GetFullPath(Path, Name);
@ -246,8 +236,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long OpenFile(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
int FilterFlags = Context.RequestData.ReadInt32();
string Name = ReadUtf8String(Context);
@ -282,8 +270,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long OpenDirectory(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
int FilterFlags = Context.RequestData.ReadInt32();
string Name = ReadUtf8String(Context);
@ -321,8 +307,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long GetFreeSpaceSize(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context);
Context.ResponseData.Write(Context.Ns.VFs.GetDrive().AvailableFreeSpace);
@ -332,8 +316,6 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
public long GetTotalSpaceSize(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
string Name = ReadUtf8String(Context);
Context.ResponseData.Write(Context.Ns.VFs.GetDrive().TotalSize);
@ -341,6 +323,37 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
return 0;
}
public long CleanDirectoryRecursively(ServiceCtx Context)
{
string Name = ReadUtf8String(Context);
string DirName = Context.Ns.VFs.GetFullPath(Path, Name);
if (!Directory.Exists(DirName))
{
return MakeError(ErrorModule.Fs, FsErr.PathDoesNotExist);
}
if (IsPathAlreadyInUse(DirName))
{
return MakeError(ErrorModule.Fs, FsErr.PathAlreadyInUse);
}
foreach (string Entry in Directory.EnumerateFileSystemEntries(DirName))
{
if (Directory.Exists(Entry))
{
Directory.Delete(Entry, true);
}
else if (File.Exists(Entry))
{
File.Delete(Entry);
}
}
return 0;
}
private bool IsPathAlreadyInUse(string Path)
{
lock (OpenPaths)