mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 10:36:44 +00:00
Bugfix crash unauthorized delete
This commit is contained in:
parent
b09ab4bdff
commit
fa39689e3a
1 changed files with 15 additions and 8 deletions
|
@ -426,19 +426,26 @@ public class FileSystem : IComponent
|
|||
L.Error("path not found");
|
||||
}
|
||||
|
||||
var attr = File.GetAttributes(path);
|
||||
if (attr.HasFlag(FileAttributes.Directory))
|
||||
try
|
||||
{
|
||||
if (!recursive && Directory.GetFileSystemEntries(path).Any())
|
||||
var attr = File.GetAttributes(path);
|
||||
if (attr.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
L.Error("directory not empty");
|
||||
return 0;
|
||||
if (!recursive && Directory.GetFileSystemEntries(path).Any())
|
||||
{
|
||||
L.Error("directory not empty");
|
||||
return 0;
|
||||
}
|
||||
Directory.Delete(path, recursive);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
Directory.Delete(path, recursive);
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
File.Delete(path);
|
||||
return L.Error(e.Message);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue