mirror of
https://github.com/kwsch/pkNX.git
synced 2026-09-30 13:16:58 -05:00
Add delete mode options for VFS
This commit is contained in:
@@ -212,9 +212,26 @@ public void CreateDirectory(FileSystemPath path)
|
||||
fs.CreateDirectory(path);
|
||||
}
|
||||
|
||||
public void Delete(FileSystemPath path)
|
||||
public void Delete(FileSystemPath path, DeleteMode mode = DeleteMode.TopMostLayer)
|
||||
{
|
||||
foreach (var fs in FileSystems.Where(fs => fs.Exists(path)))
|
||||
fs.Delete(path);
|
||||
switch (mode)
|
||||
{
|
||||
case DeleteMode.TopMostLayer:
|
||||
GetFirstWhereExists(path)?.Delete(path);
|
||||
break;
|
||||
case DeleteMode.TopMostWriteableLayer:
|
||||
GetFirstWritableWhereExists(path)?.Delete(path);
|
||||
break;
|
||||
case DeleteMode.AllWritable:
|
||||
foreach (var fs in FileSystems.Where(fs => !fs.IsReadOnly && fs.Exists(path)))
|
||||
fs.Delete(path);
|
||||
break;
|
||||
case DeleteMode.All:
|
||||
foreach (var fs in FileSystems.Where(fs => fs.Exists(path)))
|
||||
fs.Delete(path);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user