mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Symbian Installation File] Adjust parsing so options are parsed first to have their name available when used as conditions.
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Aaru.Archives;
|
namespace Aaru.Archives;
|
||||||
@@ -172,7 +173,19 @@ public sealed partial class Symbian
|
|||||||
};
|
};
|
||||||
|
|
||||||
if((int)attributeExpression.attribute > 0x2000)
|
if((int)attributeExpression.attribute > 0x2000)
|
||||||
sb.Append($"option({attributeExpression.attribute - 0x2000}, ENABLED)");
|
{
|
||||||
|
int optionIndex = (int)attributeExpression.attribute - 0x2000;
|
||||||
|
|
||||||
|
if(optionIndex <= _options.Count)
|
||||||
|
{
|
||||||
|
OptionRecord option = _options[optionIndex - 1];
|
||||||
|
option.names.TryGetValue("EN", out string optionName);
|
||||||
|
optionName ??= option.names.Values.FirstOrDefault() ?? optionIndex.ToString();
|
||||||
|
sb.Append($"option(\"{optionName}\", ENABLED)");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sb.Append($"option({optionIndex}, ENABLED");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sb.Append($"{attributeExpression.attribute}");
|
sb.Append($"{attributeExpression.attribute}");
|
||||||
|
|
||||||
@@ -270,7 +283,19 @@ public sealed partial class Symbian
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sb.Append($"option({attribute.Value - 0x2000}, {(numberExpression.number > 0 ? "ENABLED" : "DISABLED")})");
|
{
|
||||||
|
int optionIndex = (int)attribute - 0x2000;
|
||||||
|
|
||||||
|
if(optionIndex <= _options.Count)
|
||||||
|
{
|
||||||
|
OptionRecord option = _options[optionIndex - 1];
|
||||||
|
option.names.TryGetValue("EN", out string optionName);
|
||||||
|
optionName ??= option.names.Values.FirstOrDefault() ?? optionIndex.ToString();
|
||||||
|
sb.Append($"option(\"{optionName}\", {(numberExpression.number == 0 ? "DISABLED" : "ENABLED")})");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sb.Append($"option({optionIndex}, {(numberExpression.number == 0 ? "DISABLED" : "ENABLED")}");
|
||||||
|
}
|
||||||
|
|
||||||
attribute = null;
|
attribute = null;
|
||||||
|
|
||||||
|
|||||||
@@ -303,9 +303,19 @@ public sealed partial class Symbian
|
|||||||
var conditionLevel = 0;
|
var conditionLevel = 0;
|
||||||
_options = new List<OptionRecord>();
|
_options = new List<OptionRecord>();
|
||||||
|
|
||||||
|
// Get only the options records
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel);
|
Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel, true);
|
||||||
|
} while(currentFile < sh.files);
|
||||||
|
|
||||||
|
// Get all other records
|
||||||
|
offset = sh.files_ptr;
|
||||||
|
currentFile = 0;
|
||||||
|
conditionLevel = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel, false);
|
||||||
} while(currentFile < sh.files);
|
} while(currentFile < sh.files);
|
||||||
|
|
||||||
description.AppendLine();
|
description.AppendLine();
|
||||||
|
|||||||
@@ -132,9 +132,19 @@ public sealed partial class Symbian
|
|||||||
uint offset = sh.files_ptr;
|
uint offset = sh.files_ptr;
|
||||||
var conditionLevel = 0;
|
var conditionLevel = 0;
|
||||||
|
|
||||||
|
// Get only the options records
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel);
|
Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel, true);
|
||||||
|
} while(currentFile < sh.files);
|
||||||
|
|
||||||
|
// Get all other records
|
||||||
|
offset = sh.files_ptr;
|
||||||
|
currentFile = 0;
|
||||||
|
conditionLevel = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Parse(br, ref offset, ref currentFile, sh.files, languages, ref conditionLevel, false);
|
||||||
} while(currentFile < sh.files);
|
} while(currentFile < sh.files);
|
||||||
|
|
||||||
// Files appear on .sis in the reverse order they should be processed
|
// Files appear on .sis in the reverse order they should be processed
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Aaru.Archives;
|
|||||||
public sealed partial class Symbian
|
public sealed partial class Symbian
|
||||||
{
|
{
|
||||||
void Parse(BinaryReader br, ref uint offset, ref uint currentFile, uint maxFiles, List<string> languages,
|
void Parse(BinaryReader br, ref uint offset, ref uint currentFile, uint maxFiles, List<string> languages,
|
||||||
ref int conditionLevel)
|
ref int conditionLevel, bool optionsOnly)
|
||||||
{
|
{
|
||||||
currentFile++;
|
currentFile++;
|
||||||
|
|
||||||
@@ -84,6 +84,9 @@ public sealed partial class Symbian
|
|||||||
if(!_release6)
|
if(!_release6)
|
||||||
offset -= sizeof(uint) * 3;
|
offset -= sizeof(uint) * 3;
|
||||||
|
|
||||||
|
if(optionsOnly)
|
||||||
|
break;
|
||||||
|
|
||||||
var decodedFileRecord = new DecodedFileRecord
|
var decodedFileRecord = new DecodedFileRecord
|
||||||
{
|
{
|
||||||
type = simpleFileRecord.record.type,
|
type = simpleFileRecord.record.type,
|
||||||
@@ -276,6 +279,8 @@ public sealed partial class Symbian
|
|||||||
multipleFileRecord.originalLengths = multipleFileRecord.lengths;
|
multipleFileRecord.originalLengths = multipleFileRecord.lengths;
|
||||||
|
|
||||||
offset = (uint)br.BaseStream.Position;
|
offset = (uint)br.BaseStream.Position;
|
||||||
|
if(optionsOnly)
|
||||||
|
break;
|
||||||
|
|
||||||
br.BaseStream.Seek(multipleFileRecord.record.sourceNamePtr, SeekOrigin.Begin);
|
br.BaseStream.Seek(multipleFileRecord.record.sourceNamePtr, SeekOrigin.Begin);
|
||||||
buffer = br.ReadBytes((int)multipleFileRecord.record.sourceNameLen);
|
buffer = br.ReadBytes((int)multipleFileRecord.record.sourceNameLen);
|
||||||
@@ -485,6 +490,7 @@ public sealed partial class Symbian
|
|||||||
|
|
||||||
br.BaseStream.Seek(offset, SeekOrigin.Begin);
|
br.BaseStream.Seek(offset, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
if(optionsOnly)
|
||||||
_options.Add(optionsLineRecord.options[i]);
|
_options.Add(optionsLineRecord.options[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,6 +511,10 @@ public sealed partial class Symbian
|
|||||||
};
|
};
|
||||||
|
|
||||||
offset = (uint)(br.BaseStream.Position + conditionalRecord.length);
|
offset = (uint)(br.BaseStream.Position + conditionalRecord.length);
|
||||||
|
|
||||||
|
if(optionsOnly)
|
||||||
|
break;
|
||||||
|
|
||||||
conditionSb = new StringBuilder();
|
conditionSb = new StringBuilder();
|
||||||
nullAttribute = null;
|
nullAttribute = null;
|
||||||
|
|
||||||
@@ -528,6 +538,10 @@ public sealed partial class Symbian
|
|||||||
};
|
};
|
||||||
|
|
||||||
offset = (uint)(br.BaseStream.Position + conditionalRecord.length);
|
offset = (uint)(br.BaseStream.Position + conditionalRecord.length);
|
||||||
|
|
||||||
|
if(optionsOnly)
|
||||||
|
break;
|
||||||
|
|
||||||
conditionSb = new StringBuilder();
|
conditionSb = new StringBuilder();
|
||||||
nullAttribute = null;
|
nullAttribute = null;
|
||||||
|
|
||||||
@@ -544,15 +558,23 @@ public sealed partial class Symbian
|
|||||||
tabulationChars[i] = '\t';
|
tabulationChars[i] = '\t';
|
||||||
tabulation = new string(tabulationChars);
|
tabulation = new string(tabulationChars);
|
||||||
|
|
||||||
_conditions.Add(tabulation + "else");
|
|
||||||
offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>());
|
offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>());
|
||||||
|
|
||||||
|
if(optionsOnly)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_conditions.Add(tabulation + "else");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FileRecordType.EndIf:
|
case FileRecordType.EndIf:
|
||||||
conditionLevel++;
|
conditionLevel++;
|
||||||
_conditions.Add(tabulation + "endif()" + Environment.NewLine);
|
|
||||||
offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>());
|
offset = (uint)(br.BaseStream.Position + Marshal.SizeOf<ConditionalEndRecord>());
|
||||||
|
|
||||||
|
if(optionsOnly)
|
||||||
|
break;
|
||||||
|
|
||||||
|
_conditions.Add(tabulation + "endif()" + Environment.NewLine);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FileRecordType.Skip:
|
case FileRecordType.Skip:
|
||||||
offset = (uint)br.BaseStream.Seek(sizeof(FileRecordType), SeekOrigin.Current);
|
offset = (uint)br.BaseStream.Seek(sizeof(FileRecordType), SeekOrigin.Current);
|
||||||
|
|||||||
Reference in New Issue
Block a user