implement ifilesys:cleandirectoryrecursively

This commit is contained in:
emmaus 2018-07-18 11:20:04 +00:00
parent 5d698a7d8d
commit f74447ed92

View file

@ -35,7 +35,7 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
{ 10, Commit },
{ 11, GetFreeSpaceSize },
{ 12, GetTotalSpaceSize },
//{ 13, CleanDirectoryRecursively },
{ 13, CleanDirectoryRecursively },
//{ 14, GetFileTimeStampRaw }
};
@ -341,6 +341,39 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
return 0;
}
public long CleanDirectoryRecursively(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;
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)