in src/managed/DiffGen/archives/Ext4Archives/Ext4Archive.cs [68:140]
public override bool TryTokenize(ItemDefinition archiveItem, out ArchiveTokenization tokens)
{
string jsonFile = archiveItem.GetExtractionPath(Context.WorkingFolder) + ".ext4.json";
try
{
using var fileFromStream = new FileFromStream(Context.Stream, Context.WorkingFolder);
var archivePath = fileFromStream.Name;
using (Process process = new())
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = ProcessHelper.GetPathInRunningDirectory(DumpextfsPath);
process.StartInfo.Arguments = $"\"{archivePath}\" \"{jsonFile}\"";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.OutputDataReceived += (sender, e) =>
{
if (e.Data is null)
{
return;
}
LogInformation(e.Data);
};
process.ErrorDataReceived += (sender, e) =>
{
if (e.Data is not null)
{
LogError(e.Data);
}
};
process.StartAndReport();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit(FiveMinutesInMilliseconds, Context.CancellationToken);
if (!process.HasExited)
{
LogError($"{DumpextfsPath} failed to load file within timeout of {FiveMinutesInMilliseconds} milliseconds.");
tokens = null;
return false;
}
if (process.ExitCode != 0)
{
LogError($"{DumpextfsPath} failed to parse the provided file: {archivePath}. Exit Code: {process.ExitCode}");
tokens = null;
return false;
}
tokens = ArchiveTokenization.FromJsonPath(jsonFile);
}
}
catch (Exception e)
{
LogError($"[Tokenization of file as ext4 failed. Error: {e.Message}]");
if (File.Exists(jsonFile))
{
LogError($"[ext4 JsonFile: {jsonFile}]");
}
tokens = null;
return false;
}
return true;
}