implement ifilesys:cleandirectoryrecursively
This commit is contained in:
parent
5d698a7d8d
commit
f74447ed92
1 changed files with 34 additions and 1 deletions
|
@ -35,7 +35,7 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
|
||||||
{ 10, Commit },
|
{ 10, Commit },
|
||||||
{ 11, GetFreeSpaceSize },
|
{ 11, GetFreeSpaceSize },
|
||||||
{ 12, GetTotalSpaceSize },
|
{ 12, GetTotalSpaceSize },
|
||||||
//{ 13, CleanDirectoryRecursively },
|
{ 13, CleanDirectoryRecursively },
|
||||||
//{ 14, GetFileTimeStampRaw }
|
//{ 14, GetFileTimeStampRaw }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -341,6 +341,39 @@ namespace Ryujinx.HLE.OsHle.Services.FspSrv
|
||||||
return 0;
|
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)
|
private bool IsPathAlreadyInUse(string Path)
|
||||||
{
|
{
|
||||||
lock (OpenPaths)
|
lock (OpenPaths)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue