You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Added safety checks on delete functions in APIDocTool
[CL 2458175 by bruce nesbit in Main branch]
This commit is contained in:
@@ -59,8 +59,10 @@ namespace APIDocTool
|
||||
}
|
||||
}
|
||||
|
||||
public static void SafeDeleteFile(string Path)
|
||||
// Returns false if delete fails
|
||||
public static bool SafeDeleteFile(string Path)
|
||||
{
|
||||
bool bResult = true;
|
||||
if (File.Exists(Path))
|
||||
{
|
||||
FileAttributes Attributes = File.GetAttributes(Path);
|
||||
@@ -68,22 +70,36 @@ namespace APIDocTool
|
||||
{
|
||||
File.SetAttributes(Path, Attributes & ~FileAttributes.ReadOnly);
|
||||
}
|
||||
File.Delete(Path);
|
||||
try
|
||||
{
|
||||
File.Delete(Path);
|
||||
}
|
||||
catch (IOException Ex)
|
||||
{
|
||||
Console.WriteLine("Failed to delete '{0}':\n{1}", Path, Ex);
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
public static void SafeDeleteDirectory(string Dir)
|
||||
// Returns false if delete fails
|
||||
public static bool SafeDeleteDirectory(string Dir)
|
||||
{
|
||||
bool bResult = true;
|
||||
if (Directory.Exists(Dir))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(Dir, true);
|
||||
}
|
||||
catch(IOException)
|
||||
catch (IOException Ex)
|
||||
{
|
||||
Console.WriteLine("Failed to delete directory '{0}':\n{1}", Path, Ex);
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
public static void SafeDeleteDirectoryContents(string Dir, bool bIncludeSubDirectories)
|
||||
|
||||
Reference in New Issue
Block a user