Fix build tool crash when includes cache file is corrupted
This commit is contained in:
@@ -26,6 +26,8 @@ namespace Flax.Build.NativeCpp
|
||||
if (!File.Exists(CachePath))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
using (var stream = new FileStream(CachePath, FileMode.Open))
|
||||
using (var reader = new BinaryReader(stream))
|
||||
{
|
||||
@@ -84,6 +86,15 @@ namespace Flax.Build.NativeCpp
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Clear cache in case of error when loading data (eg. corrupted file)
|
||||
DirectIncludesCache.Clear();
|
||||
AllIncludesCache.Clear();
|
||||
DirectIncludesTimestampCache.Clear();
|
||||
AllIncludesTimestampCache.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveCache()
|
||||
{
|
||||
@@ -305,7 +316,7 @@ namespace Flax.Build.NativeCpp
|
||||
if (includedFile.EndsWith('\\'))
|
||||
{
|
||||
int j = includeStart;
|
||||
while (j-- > 1 && fileContents[j-1] != '\n')
|
||||
while (j-- > 1 && fileContents[j - 1] != '\n')
|
||||
{
|
||||
}
|
||||
var injectCode = fileContents.Substring(j, "API_INJECT_CODE".Length);
|
||||
|
||||
Reference in New Issue
Block a user