update to 0.6.9
This commit is contained in:
parent
5c4cd7a5b0
commit
722279aad5
|
@ -0,0 +1,221 @@
|
||||||
|
unit Unit1;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
System.SysUtils, System.Types, System.UITypes, System.Classes,
|
||||||
|
System.Variants, System.Math, System.StrUtils,
|
||||||
|
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl,
|
||||||
|
FMX.Layouts, FMX.ListBox, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit,
|
||||||
|
FMX.EditBox, FMX.SpinBox, FMX.Menus;
|
||||||
|
|
||||||
|
type
|
||||||
|
TForm1 = class(TForm)
|
||||||
|
StyleBook1: TStyleBook;
|
||||||
|
SaveDialog1: TSaveDialog;
|
||||||
|
OpenDialog1: TOpenDialog;
|
||||||
|
Layout4: TLayout;
|
||||||
|
Button1: TButton;
|
||||||
|
GroupBox1: TGroupBox;
|
||||||
|
ComboBox2: TComboBox;
|
||||||
|
Edit1: TEdit;
|
||||||
|
SearchEditButton1: TSearchEditButton;
|
||||||
|
Layout1: TLayout;
|
||||||
|
GroupBox2: TGroupBox;
|
||||||
|
Layout3: TLayout;
|
||||||
|
VertScrollBox1: TVertScrollBox;
|
||||||
|
GroupBox3: TGroupBox;
|
||||||
|
Layout7: TLayout;
|
||||||
|
Edit3: TEdit;
|
||||||
|
SearchEditButton3: TSearchEditButton;
|
||||||
|
ComboBox3: TComboBox;
|
||||||
|
Label1: TLabel;
|
||||||
|
SpinBox1: TSpinBox;
|
||||||
|
Label2: TLabel;
|
||||||
|
SpinBox2: TSpinBox;
|
||||||
|
CheckBox1: TCheckBox;
|
||||||
|
Layout2: TLayout;
|
||||||
|
Label3: TLabel;
|
||||||
|
SpinBox3: TSpinBox;
|
||||||
|
GroupBox4: TGroupBox;
|
||||||
|
Layout6: TLayout;
|
||||||
|
GroupBox5: TGroupBox;
|
||||||
|
Layout8: TLayout;
|
||||||
|
Label7: TLabel;
|
||||||
|
SpinBox7: TSpinBox;
|
||||||
|
CheckBox5: TCheckBox;
|
||||||
|
CheckBox3: TCheckBox;
|
||||||
|
Label4: TLabel;
|
||||||
|
SpinBox4: TSpinBox;
|
||||||
|
CheckBox4: TCheckBox;
|
||||||
|
PopupMenu1: TPopupMenu;
|
||||||
|
MenuItem1: TMenuItem;
|
||||||
|
GroupBox6: TGroupBox;
|
||||||
|
Layout5: TLayout;
|
||||||
|
Edit2: TEdit;
|
||||||
|
Button2: TButton;
|
||||||
|
GroupBox7: TGroupBox;
|
||||||
|
Layout9: TLayout;
|
||||||
|
Edit4: TEdit;
|
||||||
|
SearchEditButton2: TSearchEditButton;
|
||||||
|
ComboBox1: TComboBox;
|
||||||
|
CheckBox2: TCheckBox;
|
||||||
|
CheckBox6: TCheckBox;
|
||||||
|
GroupBox8: TGroupBox;
|
||||||
|
Layout10: TLayout;
|
||||||
|
Edit5: TEdit;
|
||||||
|
SearchEditButton4: TSearchEditButton;
|
||||||
|
ComboBox4: TComboBox;
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure SearchEditButton1Click(Sender: TObject);
|
||||||
|
procedure SearchEditButton3Click(Sender: TObject);
|
||||||
|
procedure ComboBox3Change(Sender: TObject);
|
||||||
|
procedure Button2Click(Sender: TObject);
|
||||||
|
procedure ComboBox2Change(Sender: TObject);
|
||||||
|
procedure Button1Click(Sender: TObject);
|
||||||
|
procedure ComboBox1Change(Sender: TObject);
|
||||||
|
procedure SearchEditButton2Click(Sender: TObject);
|
||||||
|
procedure ComboBox4Change(Sender: TObject);
|
||||||
|
procedure SearchEditButton4Click(Sender: TObject);
|
||||||
|
private
|
||||||
|
{ Private declarations }
|
||||||
|
public
|
||||||
|
{ Public declarations }
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Form1: TForm1;
|
||||||
|
CmdStr: TArray<String>;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.fmx}
|
||||||
|
|
||||||
|
uses
|
||||||
|
Unit2;
|
||||||
|
|
||||||
|
procedure TForm1.Button1Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SetLength(CmdStr, 0);
|
||||||
|
Insert(ParamStr(0), CmdStr, Length(CmdStr));
|
||||||
|
Insert('precomp', CmdStr, Length(CmdStr));
|
||||||
|
Insert('-c' + SpinBox1.Text + 'mb', CmdStr, Length(CmdStr));
|
||||||
|
Insert('-t' + SpinBox2.Text, CmdStr, Length(CmdStr));
|
||||||
|
if CheckBox1.IsChecked then
|
||||||
|
Insert('-lm', CmdStr, Length(CmdStr));
|
||||||
|
Insert('-d' + SpinBox3.Text, CmdStr, Length(CmdStr));
|
||||||
|
if CheckBox2.IsChecked then
|
||||||
|
Insert('-s', CmdStr, Length(CmdStr));
|
||||||
|
if CheckBox6.IsChecked then
|
||||||
|
Insert('-v', CmdStr, Length(CmdStr));
|
||||||
|
Insert('-m' + Edit2.Text, CmdStr, Length(CmdStr));
|
||||||
|
if ComboBox1.ItemIndex = 1 then
|
||||||
|
Insert('-db', CmdStr, Length(CmdStr))
|
||||||
|
else if ComboBox1.ItemIndex > 1 then
|
||||||
|
Insert('-db' + Edit4.Text, CmdStr, Length(CmdStr));
|
||||||
|
if CheckBox3.IsChecked then
|
||||||
|
Insert('-dd' + IfThen(SpinBox4.Enabled, SpinBox4.Text, ''), CmdStr,
|
||||||
|
Length(CmdStr));
|
||||||
|
if CheckBox4.IsChecked then
|
||||||
|
Insert('--compress=' + 't' + SpinBox2.Text + ':l' + SpinBox7.Text + ':hi' +
|
||||||
|
IfThen(CheckBox5.IsChecked, '1', '0'), CmdStr, Length(CmdStr));
|
||||||
|
Insert(Edit1.Text, CmdStr, Length(CmdStr));
|
||||||
|
if ComboBox3.ItemIndex = 0 then
|
||||||
|
Insert(Edit3.Text, CmdStr, Length(CmdStr));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.Button2Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Form2.Left := Form1.Left + (Form1.Width div 2) - (Form2.Width div 2);
|
||||||
|
Form2.Top := Form1.Top + (Form1.Height div 2) - (Form2.Height div 2);
|
||||||
|
Form2.ShowModal;
|
||||||
|
Form2.Close;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.ComboBox1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Edit4.Enabled := ComboBox1.ItemIndex in [2, 3];
|
||||||
|
Edit4.Text := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.ComboBox2Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SearchEditButton1.Enabled := ComboBox2.ItemIndex <> 2;
|
||||||
|
Edit1.ReadOnly := ComboBox2.ItemIndex <> 2;
|
||||||
|
if ComboBox2.ItemIndex = 2 then
|
||||||
|
Edit1.Text := 'http://mattmahoney.net/dc/silesia.zip'
|
||||||
|
else
|
||||||
|
Edit1.Text := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.ComboBox3Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Edit3.Enabled := ComboBox3.ItemIndex <> 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.ComboBox4Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Edit5.Enabled := ComboBox4.ItemIndex > 0;
|
||||||
|
Edit5.Text := '';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.FormShow(Sender: TObject);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
for I := 0 to ComponentCount - 1 do
|
||||||
|
if Components[I] is TSpinBox then
|
||||||
|
TSpinBox(Components[I]).Cursor := crDefault;
|
||||||
|
SpinBox2.Max := CPUCount * 2;
|
||||||
|
SpinBox2.Value := Max(1, CPUCount div 2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.SearchEditButton1Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
Dir: string;
|
||||||
|
begin
|
||||||
|
case ComboBox2.ItemIndex of
|
||||||
|
0:
|
||||||
|
begin
|
||||||
|
OpenDialog1.FileName := '';
|
||||||
|
if OpenDialog1.Execute then
|
||||||
|
Edit1.Text := OpenDialog1.FileName;
|
||||||
|
end;
|
||||||
|
1:
|
||||||
|
if SelectDirectory('', '', Dir) then
|
||||||
|
Edit1.Text := Dir;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.SearchEditButton2Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if ComboBox1.ItemIndex = 2 then
|
||||||
|
begin
|
||||||
|
SaveDialog1.FileName := '';
|
||||||
|
if SaveDialog1.Execute then
|
||||||
|
Edit4.Text := SaveDialog1.FileName;
|
||||||
|
end
|
||||||
|
else if ComboBox1.ItemIndex = 3 then
|
||||||
|
begin
|
||||||
|
OpenDialog1.FileName := '';
|
||||||
|
if OpenDialog1.Execute then
|
||||||
|
Edit4.Text := OpenDialog1.FileName;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.SearchEditButton3Click(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SaveDialog1.FileName := '';
|
||||||
|
if SaveDialog1.Execute then
|
||||||
|
Edit3.Text := SaveDialog1.FileName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.SearchEditButton4Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
Dir: string;
|
||||||
|
begin
|
||||||
|
if SelectDirectory('', '', Dir) then
|
||||||
|
Edit5.Text := Dir;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
|
@ -0,0 +1,562 @@
|
||||||
|
unit Unit2;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
System.SysUtils, System.Types, System.UITypes, System.Classes,
|
||||||
|
System.Variants, System.Math, System.StrUtils,
|
||||||
|
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl,
|
||||||
|
FMX.StdCtrls, FMX.Edit, FMX.EditBox, FMX.SpinBox, FMX.Controls.Presentation,
|
||||||
|
FMX.Layouts, FMX.ListBox;
|
||||||
|
|
||||||
|
type
|
||||||
|
TForm2 = class(TForm)
|
||||||
|
TabControl1: TTabControl;
|
||||||
|
TabItem1: TTabItem;
|
||||||
|
TabItem2: TTabItem;
|
||||||
|
Expander1: TExpander;
|
||||||
|
Layout6: TLayout;
|
||||||
|
CheckBox3: TCheckBox;
|
||||||
|
Layout1: TLayout;
|
||||||
|
Label4: TLabel;
|
||||||
|
SpinBox4: TSpinBox;
|
||||||
|
Layout2: TLayout;
|
||||||
|
CheckBox1: TCheckBox;
|
||||||
|
Layout3: TLayout;
|
||||||
|
Label1: TLabel;
|
||||||
|
SpinBox1: TSpinBox;
|
||||||
|
Layout4: TLayout;
|
||||||
|
CheckBox2: TCheckBox;
|
||||||
|
Expander2: TExpander;
|
||||||
|
Layout5: TLayout;
|
||||||
|
CheckBox4: TCheckBox;
|
||||||
|
Layout7: TLayout;
|
||||||
|
Label2: TLabel;
|
||||||
|
SpinBox2: TSpinBox;
|
||||||
|
Layout8: TLayout;
|
||||||
|
CheckBox5: TCheckBox;
|
||||||
|
Layout9: TLayout;
|
||||||
|
SpinBox3: TSpinBox;
|
||||||
|
Layout10: TLayout;
|
||||||
|
CheckBox6: TCheckBox;
|
||||||
|
VertScrollBox1: TVertScrollBox;
|
||||||
|
Layout11: TLayout;
|
||||||
|
SpinBox5: TSpinBox;
|
||||||
|
Layout12: TLayout;
|
||||||
|
Label6: TLabel;
|
||||||
|
SpinBox6: TSpinBox;
|
||||||
|
Expander3: TExpander;
|
||||||
|
Layout13: TLayout;
|
||||||
|
CheckBox7: TCheckBox;
|
||||||
|
Layout14: TLayout;
|
||||||
|
Label7: TLabel;
|
||||||
|
Layout15: TLayout;
|
||||||
|
SpinBox8: TSpinBox;
|
||||||
|
ComboBox1: TComboBox;
|
||||||
|
Expander4: TExpander;
|
||||||
|
Layout16: TLayout;
|
||||||
|
CheckBox8: TCheckBox;
|
||||||
|
Layout18: TLayout;
|
||||||
|
SpinBox7: TSpinBox;
|
||||||
|
CheckBox9: TCheckBox;
|
||||||
|
Expander5: TExpander;
|
||||||
|
Layout17: TLayout;
|
||||||
|
CheckBox10: TCheckBox;
|
||||||
|
Layout19: TLayout;
|
||||||
|
SpinBox9: TSpinBox;
|
||||||
|
CheckBox11: TCheckBox;
|
||||||
|
Layout20: TLayout;
|
||||||
|
CheckBox12: TCheckBox;
|
||||||
|
Layout21: TLayout;
|
||||||
|
SpinBox10: TSpinBox;
|
||||||
|
CheckBox13: TCheckBox;
|
||||||
|
Layout22: TLayout;
|
||||||
|
CheckBox14: TCheckBox;
|
||||||
|
Layout23: TLayout;
|
||||||
|
SpinBox11: TSpinBox;
|
||||||
|
CheckBox15: TCheckBox;
|
||||||
|
Layout24: TLayout;
|
||||||
|
CheckBox16: TCheckBox;
|
||||||
|
Layout25: TLayout;
|
||||||
|
SpinBox12: TSpinBox;
|
||||||
|
CheckBox17: TCheckBox;
|
||||||
|
Layout26: TLayout;
|
||||||
|
CheckBox18: TCheckBox;
|
||||||
|
Layout27: TLayout;
|
||||||
|
SpinBox13: TSpinBox;
|
||||||
|
CheckBox19: TCheckBox;
|
||||||
|
Layout28: TLayout;
|
||||||
|
CheckBox20: TCheckBox;
|
||||||
|
Expander6: TExpander;
|
||||||
|
Layout29: TLayout;
|
||||||
|
CheckBox21: TCheckBox;
|
||||||
|
Layout30: TLayout;
|
||||||
|
SpinBox14: TSpinBox;
|
||||||
|
CheckBox23: TCheckBox;
|
||||||
|
CheckBox24: TCheckBox;
|
||||||
|
CheckBox25: TCheckBox;
|
||||||
|
Layout31: TLayout;
|
||||||
|
Label3: TLabel;
|
||||||
|
SpinBox15: TSpinBox;
|
||||||
|
Layout32: TLayout;
|
||||||
|
CheckBox26: TCheckBox;
|
||||||
|
Layout33: TLayout;
|
||||||
|
RadioButton1: TRadioButton;
|
||||||
|
Layout34: TLayout;
|
||||||
|
RadioButton2: TRadioButton;
|
||||||
|
Layout35: TLayout;
|
||||||
|
RadioButton3: TRadioButton;
|
||||||
|
Layout36: TLayout;
|
||||||
|
Label5: TLabel;
|
||||||
|
SpinBox16: TSpinBox;
|
||||||
|
Layout37: TLayout;
|
||||||
|
Button1: TButton;
|
||||||
|
RadioButton4: TRadioButton;
|
||||||
|
VertScrollBox3: TVertScrollBox;
|
||||||
|
Expander10: TExpander;
|
||||||
|
ListBox2: TListBox;
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure CheckBox3Change(Sender: TObject);
|
||||||
|
procedure CheckBox1Change(Sender: TObject);
|
||||||
|
procedure CheckBox4Change(Sender: TObject);
|
||||||
|
procedure CheckBox5Change(Sender: TObject);
|
||||||
|
procedure CheckBox6Change(Sender: TObject);
|
||||||
|
procedure CheckBox7Change(Sender: TObject);
|
||||||
|
procedure CheckBox10Change(Sender: TObject);
|
||||||
|
procedure CheckBox8Change(Sender: TObject);
|
||||||
|
procedure CheckBox12Change(Sender: TObject);
|
||||||
|
procedure CheckBox14Change(Sender: TObject);
|
||||||
|
procedure CheckBox16Change(Sender: TObject);
|
||||||
|
procedure CheckBox18Change(Sender: TObject);
|
||||||
|
procedure CheckBox21Change(Sender: TObject);
|
||||||
|
procedure CheckBox26Change(Sender: TObject);
|
||||||
|
procedure CheckBox24Change(Sender: TObject);
|
||||||
|
procedure CheckBox23Change(Sender: TObject);
|
||||||
|
procedure CheckBox25Change(Sender: TObject);
|
||||||
|
procedure CheckBox9Change(Sender: TObject);
|
||||||
|
procedure CheckBox11Change(Sender: TObject);
|
||||||
|
procedure CheckBox13Change(Sender: TObject);
|
||||||
|
procedure CheckBox15Change(Sender: TObject);
|
||||||
|
procedure CheckBox17Change(Sender: TObject);
|
||||||
|
procedure CheckBox19Change(Sender: TObject);
|
||||||
|
procedure Button1Click(Sender: TObject);
|
||||||
|
procedure RadioButton4Change(Sender: TObject);
|
||||||
|
private
|
||||||
|
{ Private declarations }
|
||||||
|
public
|
||||||
|
{ Public declarations }
|
||||||
|
end;
|
||||||
|
|
||||||
|
TMethod = record
|
||||||
|
FName: String;
|
||||||
|
FType: Integer;
|
||||||
|
Codecs: TArray<String>;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TConfigCtrl = class(TObject)
|
||||||
|
private
|
||||||
|
FOwner, FParent: TFmxObject;
|
||||||
|
FExpander: TExpander;
|
||||||
|
FListBox: TListBox;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner, AParent: TFmxObject);
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure SetText(AText: String);
|
||||||
|
procedure AddCodec(ACodec: String);
|
||||||
|
function GetCodec(out Codec: String): Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TLibraryCtrl = class(TObject)
|
||||||
|
private
|
||||||
|
FOwner, FParent: TFmxObject;
|
||||||
|
FExpander: TExpander;
|
||||||
|
FCheckBox: TArray<TCheckBox>;
|
||||||
|
FLayout1, FLayout2: TArray<TLayout>;
|
||||||
|
FLabel: TArray<TLabel>;
|
||||||
|
FEdit: TArray<TEdit>;
|
||||||
|
procedure OnCheckBoxChange(Sender: TObject);
|
||||||
|
public
|
||||||
|
constructor Create(AOwner, AParent: TFmxObject);
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure SetText(AText: String);
|
||||||
|
procedure AddCodec(ACodec: String);
|
||||||
|
function GetCodec(out Codec: String): Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Form2: TForm2;
|
||||||
|
Methods: TArray<TMethod>;
|
||||||
|
CfgCtrls: TArray<TConfigCtrl>;
|
||||||
|
LibCtrls: TArray<TLibraryCtrl>;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{$R *.fmx}
|
||||||
|
|
||||||
|
uses Unit1;
|
||||||
|
|
||||||
|
procedure AddMethod(const SubStr: String; var ResStr: String;
|
||||||
|
ParamStr: TArray<String>; ParamBool: TArray<Boolean>);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
S: String;
|
||||||
|
begin
|
||||||
|
if ResStr = '' then
|
||||||
|
ResStr := SubStr
|
||||||
|
else
|
||||||
|
ResStr := ResStr + '+' + SubStr;
|
||||||
|
S := '';
|
||||||
|
for I := Low(ParamStr) to High(ParamStr) do
|
||||||
|
if ParamBool[I] then
|
||||||
|
S := S + ':' + ParamStr[I];
|
||||||
|
ResStr := ResStr + S;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TConfigCtrl.Create(AOwner, AParent: TFmxObject);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
FOwner := AOwner;
|
||||||
|
FParent := AParent;
|
||||||
|
FExpander := TExpander.Create(FOwner);
|
||||||
|
FExpander.Parent := FParent;
|
||||||
|
FExpander.Height := 130;
|
||||||
|
FExpander.Margins.Top := 8;
|
||||||
|
FExpander.Margins.Left := 8;
|
||||||
|
FExpander.Margins.Right := 8;
|
||||||
|
FExpander.Align := TAlignLayout.Top;
|
||||||
|
FListBox := TListBox.Create(FExpander);
|
||||||
|
FListBox.Parent := FExpander;
|
||||||
|
FListBox.Margins.Bottom := 8;
|
||||||
|
FListBox.Margins.Left := 8;
|
||||||
|
FListBox.Margins.Right := 8;
|
||||||
|
FListBox.Align := TAlignLayout.Client;
|
||||||
|
FListBox.ShowCheckboxes := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TConfigCtrl.Destroy;
|
||||||
|
begin
|
||||||
|
FListBox.Free;
|
||||||
|
FExpander.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TConfigCtrl.SetText(AText: String);
|
||||||
|
begin
|
||||||
|
FExpander.Text := AText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TConfigCtrl.AddCodec(ACodec: String);
|
||||||
|
begin
|
||||||
|
FListBox.Items.Add(ACodec);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TConfigCtrl.GetCodec(out Codec: String): Boolean;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
S: String;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
S := '';
|
||||||
|
for I := 0 to FListBox.Items.Count - 1 do
|
||||||
|
if FListBox.ItemByIndex(I).IsChecked then
|
||||||
|
begin
|
||||||
|
S := S + ':' + FListBox.Items[I];
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
if Result then
|
||||||
|
Codec := FExpander.Text + S;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TLibraryCtrl.Create(AOwner, AParent: TFmxObject);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
FOwner := AOwner;
|
||||||
|
FParent := AParent;
|
||||||
|
FExpander := TExpander.Create(FOwner);
|
||||||
|
FExpander.Parent := FParent;
|
||||||
|
FExpander.Height := 25;
|
||||||
|
FExpander.Margins.Top := 8;
|
||||||
|
FExpander.Margins.Left := 8;
|
||||||
|
FExpander.Margins.Right := 8;
|
||||||
|
FExpander.Align := TAlignLayout.Top;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TLibraryCtrl.Destroy;
|
||||||
|
begin
|
||||||
|
FExpander.Free;
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLibraryCtrl.OnCheckBoxChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
for I := Low(FCheckBox) to High(FCheckBox) do
|
||||||
|
if Sender = FCheckBox[I] then
|
||||||
|
FEdit[I].Enabled := FCheckBox[I].IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLibraryCtrl.SetText(AText: String);
|
||||||
|
begin
|
||||||
|
FExpander.Text := AText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLibraryCtrl.AddCodec(ACodec: String);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
I := Length(FLayout1);
|
||||||
|
Insert(TLayout.Create(FExpander), FLayout1, Length(FLayout1));
|
||||||
|
FLayout1[I].Parent := FExpander;
|
||||||
|
FLayout1[I].Height := 64;
|
||||||
|
FLayout1[I].Align := TAlignLayout.Top;
|
||||||
|
Insert(TCheckBox.Create(FLayout1[I]), FCheckBox, Length(FCheckBox));
|
||||||
|
FCheckBox[I].Parent := FLayout1[I];
|
||||||
|
FCheckBox[I].Height := 20;
|
||||||
|
FCheckBox[I].Margins.Top := 8;
|
||||||
|
FCheckBox[I].Margins.Left := 8;
|
||||||
|
FCheckBox[I].Margins.Right := 8;
|
||||||
|
FCheckBox[I].Align := TAlignLayout.Top;
|
||||||
|
FCheckBox[I].Text := ACodec;
|
||||||
|
FCheckBox[I].OnChange := OnCheckBoxChange;
|
||||||
|
Insert(TLayout.Create(FLayout1[I]), FLayout2, Length(FLayout2));
|
||||||
|
FLayout2[I].Parent := FLayout1[I];
|
||||||
|
FLayout2[I].Align := TAlignLayout.Client;
|
||||||
|
Insert(TLabel.Create(FLayout2[I]), FLabel, Length(FLabel));
|
||||||
|
FLabel[I].Parent := FLayout2[I];
|
||||||
|
FLabel[I].Width := 40;
|
||||||
|
FLabel[I].Margins.Top := 8;
|
||||||
|
FLabel[I].Margins.Bottom := 8;
|
||||||
|
FLabel[I].Margins.Left := 8;
|
||||||
|
FLabel[I].Align := TAlignLayout.Left;
|
||||||
|
FLabel[I].Text := 'Param';
|
||||||
|
Insert(TEdit.Create(FLayout2[I]), FEdit, Length(FEdit));
|
||||||
|
FEdit[I].Parent := FLayout2[I];
|
||||||
|
FEdit[I].Enabled := False;
|
||||||
|
FEdit[I].Margins.Top := 8;
|
||||||
|
FEdit[I].Margins.Bottom := 8;
|
||||||
|
FEdit[I].Margins.Left := 8;
|
||||||
|
FEdit[I].Margins.Right := 8;
|
||||||
|
FEdit[I].Align := TAlignLayout.Client;
|
||||||
|
FExpander.Height := FExpander.Height + 64;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TLibraryCtrl.GetCodec(out Codec: String): Boolean;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
S: String;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
S := '';
|
||||||
|
for I := Low(FCheckBox) to High(FCheckBox) do
|
||||||
|
if FCheckBox[I].IsChecked then
|
||||||
|
begin
|
||||||
|
AddMethod(FCheckBox[I].Text, S, [FEdit[I].Text], [FEdit[I].Text <> '']);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
if Result then
|
||||||
|
Codec := S;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.Button1Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
S, Res: String;
|
||||||
|
begin
|
||||||
|
Res := '';
|
||||||
|
if CheckBox3.IsChecked then
|
||||||
|
AddMethod('zlib', Res, ['w' + SpinBox4.Text], [True]);
|
||||||
|
if CheckBox1.IsChecked then
|
||||||
|
AddMethod('reflate', Res, ['l' + SpinBox1.Text], [True]);
|
||||||
|
if CheckBox2.IsChecked then
|
||||||
|
AddMethod('preflate', Res, [], []);
|
||||||
|
if CheckBox20.IsChecked then
|
||||||
|
AddMethod('png', Res, [], []);
|
||||||
|
if CheckBox4.IsChecked then
|
||||||
|
AddMethod('lz4', Res, ['a' + SpinBox2.Text], [True]);
|
||||||
|
if CheckBox5.IsChecked then
|
||||||
|
AddMethod('lz4hc', Res, ['l' + SpinBox3.Text], [CheckBox24.IsChecked]);
|
||||||
|
if CheckBox6.IsChecked then
|
||||||
|
AddMethod('lz4f', Res, ['l' + SpinBox5.Text, 'd' + SpinBox6.Text],
|
||||||
|
[CheckBox23.IsChecked, True]);
|
||||||
|
if CheckBox7.IsChecked then
|
||||||
|
AddMethod('lzo1x', Res, ['l' + SpinBox8.Text], [CheckBox25.IsChecked]);
|
||||||
|
if CheckBox8.IsChecked then
|
||||||
|
AddMethod('zstd', Res, ['l' + SpinBox7.Text], [CheckBox9.IsChecked]);
|
||||||
|
if CheckBox10.IsChecked then
|
||||||
|
AddMethod('kraken', Res, ['l' + SpinBox9.Text, 'n' + SpinBox15.Text,
|
||||||
|
't' + SpinBox16.Text], [CheckBox11.IsChecked, True, True]);
|
||||||
|
if CheckBox12.IsChecked then
|
||||||
|
AddMethod('mermaid', Res, ['l' + SpinBox10.Text, 'n' + SpinBox15.Text,
|
||||||
|
't' + SpinBox16.Text], [CheckBox13.IsChecked, True, True]);
|
||||||
|
if CheckBox14.IsChecked then
|
||||||
|
AddMethod('selkie', Res, ['l' + SpinBox11.Text, 'n' + SpinBox15.Text,
|
||||||
|
't' + SpinBox16.Text], [CheckBox15.IsChecked, True, True]);
|
||||||
|
if CheckBox16.IsChecked then
|
||||||
|
AddMethod('hydra', Res, ['l' + SpinBox12.Text, 'n' + SpinBox15.Text,
|
||||||
|
't' + SpinBox16.Text], [CheckBox17.IsChecked, True, True]);
|
||||||
|
if CheckBox18.IsChecked then
|
||||||
|
AddMethod('leviathan', Res, ['l' + SpinBox13.Text, 'n' + SpinBox15.Text,
|
||||||
|
't' + SpinBox16.Text], [CheckBox19.IsChecked, True, True]);
|
||||||
|
if CheckBox21.IsChecked then
|
||||||
|
AddMethod('flac', Res, ['l' + SpinBox14.Text], [RadioButton4.IsChecked]);
|
||||||
|
if CheckBox26.IsChecked and RadioButton1.IsChecked then
|
||||||
|
AddMethod('brunsli', Res, [], []);
|
||||||
|
if CheckBox26.IsChecked and RadioButton2.IsChecked then
|
||||||
|
AddMethod('packjpg', Res, [], []);
|
||||||
|
if CheckBox26.IsChecked and RadioButton3.IsChecked then
|
||||||
|
AddMethod('jojpeg', Res, [], []);
|
||||||
|
for I := 0 to ListBox2.Items.Count - 1 do
|
||||||
|
if ListBox2.ItemByIndex(I).IsChecked then
|
||||||
|
AddMethod(ListBox2.Items[I], Res, [], []);
|
||||||
|
for I := Low(CfgCtrls) to High(CfgCtrls) do
|
||||||
|
if CfgCtrls[I].GetCodec(S) then
|
||||||
|
AddMethod(S, Res, [], []);
|
||||||
|
for I := Low(LibCtrls) to High(LibCtrls) do
|
||||||
|
if LibCtrls[I].GetCodec(S) then
|
||||||
|
AddMethod(S, Res, [], []);
|
||||||
|
Form1.Edit2.Text := Res;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox10Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout19.Enabled := CheckBox10.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox11Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox9.Enabled := CheckBox11.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox12Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout21.Enabled := CheckBox12.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox13Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox10.Enabled := CheckBox13.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox14Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout23.Enabled := CheckBox14.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox15Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox11.Enabled := CheckBox15.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox16Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout25.Enabled := CheckBox16.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox17Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox12.Enabled := CheckBox17.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox18Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout27.Enabled := CheckBox18.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox19Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox13.Enabled := CheckBox19.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout3.Enabled := CheckBox1.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox21Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout30.Enabled := CheckBox21.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox23Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox5.Enabled := CheckBox23.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox24Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox3.Enabled := CheckBox24.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox25Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox8.Enabled := CheckBox25.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox26Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout33.Enabled := CheckBox26.IsChecked;
|
||||||
|
Layout34.Enabled := CheckBox26.IsChecked;
|
||||||
|
Layout35.Enabled := CheckBox26.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox3Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout1.Enabled := CheckBox3.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox4Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout7.Enabled := CheckBox4.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox5Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout9.Enabled := CheckBox5.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox6Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout11.Enabled := CheckBox6.IsChecked;
|
||||||
|
Layout12.Enabled := CheckBox6.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox7Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout14.Enabled := CheckBox7.IsChecked;
|
||||||
|
Layout15.Enabled := CheckBox7.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox8Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Layout18.Enabled := CheckBox8.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.CheckBox9Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox7.Enabled := CheckBox9.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.FormShow(Sender: TObject);
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
for I := 0 to ComponentCount - 1 do
|
||||||
|
begin
|
||||||
|
if Components[I] is TSpinBox then
|
||||||
|
TSpinBox(Components[I]).Cursor := crDefault;
|
||||||
|
if Components[I] is TCheckBox then
|
||||||
|
if Assigned(TCheckBox(Components[I]).OnChange) then
|
||||||
|
TCheckBox(Components[I]).OnChange(nil);
|
||||||
|
if Components[I] is TRadioButton then
|
||||||
|
if Assigned(TRadioButton(Components[I]).OnChange) then
|
||||||
|
TRadioButton(Components[I]).OnChange(nil);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm2.RadioButton4Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
SpinBox14.Enabled := RadioButton4.IsChecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
21
changes.txt
21
changes.txt
|
@ -1,3 +1,22 @@
|
||||||
|
ES_R44 (0.6.9)
|
||||||
|
- added library checker (trial and error)
|
||||||
|
- improved user interface
|
||||||
|
- fixed bugs related to oodle scanner
|
||||||
|
- skip verification no longer applies to encryption codecs
|
||||||
|
|
||||||
|
ES_R43 (0.6.8)
|
||||||
|
- added advanced configuration based plugin support
|
||||||
|
- added UI mode when xtool.exe is launched with xtoolui.dll present
|
||||||
|
- added skip verification mode
|
||||||
|
- xtool now enforces w15 deflate stream detection by default
|
||||||
|
- fixed oodle scanner exceptions when incomplete stream is detected
|
||||||
|
- fixed issue with zlib codec not accepting streams from database plugins
|
||||||
|
- updated command line syntax
|
||||||
|
|
||||||
|
ES_R42 (0.6.7)
|
||||||
|
- fixed oodle scanner exceptions when incorrect library is used
|
||||||
|
- fixed issues with deduplication feature
|
||||||
|
|
||||||
ES_R41 (0.6.6)
|
ES_R41 (0.6.6)
|
||||||
- fixed issues with exporting precompression database
|
- fixed issues with exporting precompression database
|
||||||
- fixed issues with deduplication feature consuming a lot of system memory
|
- fixed issues with deduplication feature consuming a lot of system memory
|
||||||
|
@ -6,7 +25,7 @@
|
||||||
|
|
||||||
ES_R40 (0.6.5)
|
ES_R40 (0.6.5)
|
||||||
- updated oodle scanner
|
- updated oodle scanner
|
||||||
- remove xdelta support from oodle and lzo codecs (crc mismatch often generates large diff files)
|
- removed xdelta support from oodle and lzo codecs (crc mismatch often generates large diff files)
|
||||||
|
|
||||||
ES_R39 (0.6.4)
|
ES_R39 (0.6.4)
|
||||||
- fixed issues with lzo2a and lzo1c codecs
|
- fixed issues with lzo2a and lzo1c codecs
|
||||||
|
|
172
common/Utils.pas
172
common/Utils.pas
|
@ -96,10 +96,13 @@ type
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TNullStream = class(TStream)
|
TNullStream = class(TStream)
|
||||||
|
private
|
||||||
|
FPosition, FSize: Int64;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
function Read(var Buffer; Count: LongInt): LongInt; override;
|
||||||
function Write(const Buffer; Count: LongInt): LongInt; override;
|
function Write(const Buffer; Count: LongInt): LongInt; override;
|
||||||
|
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TArrayStream = class(TStream)
|
TArrayStream = class(TStream)
|
||||||
|
@ -136,33 +139,6 @@ type
|
||||||
procedure Update(Index: Integer; MaxSize: Int64);
|
procedure Update(Index: Integer; MaxSize: Int64);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TPointersStream = class(TStream)
|
|
||||||
protected
|
|
||||||
function GetSize: Int64; override;
|
|
||||||
procedure SetSize(NewSize: LongInt); override;
|
|
||||||
procedure SetSize(const NewSize: Int64); override;
|
|
||||||
private
|
|
||||||
FPointers: TArray<Pointer>;
|
|
||||||
FSizes: TArray<NativeInt>;
|
|
||||||
FPosition, FSize: NativeInt;
|
|
||||||
FMaxSize: NativeInt;
|
|
||||||
FIndex, FCount: Integer;
|
|
||||||
FIndexPos: NativeInt;
|
|
||||||
procedure Recalculate;
|
|
||||||
public
|
|
||||||
constructor Create;
|
|
||||||
destructor Destroy; override;
|
|
||||||
function Read(var Buffer; Count: LongInt): LongInt; override;
|
|
||||||
function Write(const Buffer; Count: LongInt): LongInt; override;
|
|
||||||
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
|
|
||||||
function Add(Ptr: Pointer; Size: NativeInt): Integer;
|
|
||||||
procedure Delete(Index: Integer);
|
|
||||||
procedure Insert(Index: Integer; Ptr: Pointer; Size: NativeInt);
|
|
||||||
procedure Clear;
|
|
||||||
property Count: Integer read FCount;
|
|
||||||
property Capacity: NativeInt read FMaxSize;
|
|
||||||
end;
|
|
||||||
|
|
||||||
TMemoryStreamEx = class(TMemoryStream)
|
TMemoryStreamEx = class(TMemoryStream)
|
||||||
private
|
private
|
||||||
FOwnMemory: Boolean;
|
FOwnMemory: Boolean;
|
||||||
|
@ -255,7 +231,10 @@ type
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TBufferedStream = class(TStream)
|
TBufferedStream = class(TStream)
|
||||||
|
protected
|
||||||
|
function GetSize: Int64; override;
|
||||||
private
|
private
|
||||||
|
FSize: Int64;
|
||||||
FReadMode: Boolean;
|
FReadMode: Boolean;
|
||||||
FMemory: PByte;
|
FMemory: PByte;
|
||||||
FBufferSize: Integer;
|
FBufferSize: Integer;
|
||||||
|
@ -487,6 +466,7 @@ function GetFileList(const APath: TArray<string>; SubDir: Boolean = True)
|
||||||
procedure FileReadBuffer(Handle: THandle; var Buffer; Count: NativeInt);
|
procedure FileReadBuffer(Handle: THandle; var Buffer; Count: NativeInt);
|
||||||
procedure FileWriteBuffer(Handle: THandle; const Buffer; Count: NativeInt);
|
procedure FileWriteBuffer(Handle: THandle; const Buffer; Count: NativeInt);
|
||||||
procedure CloseHandleEx(var Handle: THandle);
|
procedure CloseHandleEx(var Handle: THandle);
|
||||||
|
function ExpandPath(const AFileName: string): String;
|
||||||
|
|
||||||
function Exec(Executable, CommandLine, WorkDir: string): Boolean;
|
function Exec(Executable, CommandLine, WorkDir: string): Boolean;
|
||||||
function ExecStdin(Executable, CommandLine, WorkDir: string; InBuff: Pointer;
|
function ExecStdin(Executable, CommandLine, WorkDir: string; InBuff: Pointer;
|
||||||
|
@ -745,18 +725,37 @@ end;
|
||||||
constructor TNullStream.Create;
|
constructor TNullStream.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
FPosition := 0;
|
||||||
|
FSize := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TNullStream.Destroy;
|
function TNullStream.Read(var Buffer; Count: LongInt): LongInt;
|
||||||
begin
|
begin
|
||||||
inherited Destroy;
|
Inc(FPosition, Count);
|
||||||
|
Result := Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TNullStream.Write(const Buffer; Count: LongInt): LongInt;
|
function TNullStream.Write(const Buffer; Count: LongInt): LongInt;
|
||||||
begin
|
begin
|
||||||
|
Inc(FPosition, Count);
|
||||||
|
if FSize < FPosition then
|
||||||
|
FSize := FPosition;
|
||||||
Result := Count;
|
Result := Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TNullStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
|
||||||
|
begin
|
||||||
|
case Origin of
|
||||||
|
soBeginning:
|
||||||
|
FPosition := Offset;
|
||||||
|
soCurrent:
|
||||||
|
Inc(FPosition, Offset);
|
||||||
|
soEnd:
|
||||||
|
FPosition := FSize + Offset;
|
||||||
|
end;
|
||||||
|
Result := Position;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TArrayStream.Create;
|
constructor TArrayStream.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
@ -948,102 +947,6 @@ begin
|
||||||
FStreams[Index].MaxSize := MaxSize;
|
FStreams[Index].MaxSize := MaxSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TPointersStream.Create;
|
|
||||||
begin
|
|
||||||
inherited Create;
|
|
||||||
Clear;
|
|
||||||
Recalculate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TPointersStream.Destroy;
|
|
||||||
begin
|
|
||||||
Clear;
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TPointersStream.GetSize: Int64;
|
|
||||||
begin
|
|
||||||
Result := FSize;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TPointersStream.SetSize(NewSize: LongInt);
|
|
||||||
begin
|
|
||||||
SetSize(Int64(NewSize));
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TPointersStream.SetSize(const NewSize: Int64);
|
|
||||||
var
|
|
||||||
OldPosition: NativeInt;
|
|
||||||
begin
|
|
||||||
OldPosition := FPosition;
|
|
||||||
if NewSize <= FMaxSize then
|
|
||||||
FSize := NewSize;
|
|
||||||
if OldPosition > NewSize then
|
|
||||||
Seek(0, soEnd);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TPointersStream.Recalculate;
|
|
||||||
var
|
|
||||||
I: Integer;
|
|
||||||
begin
|
|
||||||
FMaxSize := 0;
|
|
||||||
for I := 0 to FCount - 1 do
|
|
||||||
Inc(FMaxSize, FSizes[I]);
|
|
||||||
if FPosition > FMaxSize then
|
|
||||||
FPosition := FMaxSize;
|
|
||||||
if FSize > FMaxSize then
|
|
||||||
FSize := FMaxSize;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TPointersStream.Read(var Buffer; Count: LongInt): LongInt;
|
|
||||||
begin
|
|
||||||
// 2121212
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TPointersStream.Write(const Buffer; Count: LongInt): LongInt;
|
|
||||||
begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TPointersStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
|
|
||||||
begin
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TPointersStream.Add(Ptr: Pointer; Size: NativeInt): Integer;
|
|
||||||
begin
|
|
||||||
System.Insert(Ptr, FPointers, FCount);
|
|
||||||
System.Insert(Size, FSizes, FCount);
|
|
||||||
Result := FCount;
|
|
||||||
Inc(FCount);
|
|
||||||
Recalculate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TPointersStream.Delete(Index: Integer);
|
|
||||||
begin
|
|
||||||
System.Delete(FPointers, Index, 1);
|
|
||||||
Dec(FCount);
|
|
||||||
Recalculate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TPointersStream.Insert(Index: Integer; Ptr: Pointer; Size: NativeInt);
|
|
||||||
begin
|
|
||||||
System.Insert(Ptr, FPointers, Index);
|
|
||||||
System.Insert(Size, FSizes, Index);
|
|
||||||
Inc(FCount);
|
|
||||||
Recalculate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TPointersStream.Clear;
|
|
||||||
begin
|
|
||||||
SetLength(FPointers, 0);
|
|
||||||
SetLength(FSizes, 0);
|
|
||||||
FCount := 0;
|
|
||||||
FPosition := 0;
|
|
||||||
FSize := 0;
|
|
||||||
FMaxSize := 0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TMemoryStreamEx.Create(AOwnMemory: Boolean; const AMemory: Pointer;
|
constructor TMemoryStreamEx.Create(AOwnMemory: Boolean; const AMemory: Pointer;
|
||||||
AMaxSize: NativeInt);
|
AMaxSize: NativeInt);
|
||||||
begin
|
begin
|
||||||
|
@ -1603,6 +1506,11 @@ begin
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBufferedStream.GetSize: Int64;
|
||||||
|
begin
|
||||||
|
Result := FSize;
|
||||||
|
end;
|
||||||
|
|
||||||
function TBufferedStream.Read(var Buffer; Count: Integer): Integer;
|
function TBufferedStream.Read(var Buffer; Count: Integer): Integer;
|
||||||
var
|
var
|
||||||
I, FCount: Integer;
|
I, FCount: Integer;
|
||||||
|
@ -1643,6 +1551,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Result := Count - FCount;
|
Result := Count - FCount;
|
||||||
|
Inc(FSize, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBufferedStream.Write(const Buffer; Count: Integer): Integer;
|
function TBufferedStream.Write(const Buffer; Count: Integer): Integer;
|
||||||
|
@ -1693,6 +1602,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Result := Count - FCount;
|
Result := Count - FCount;
|
||||||
|
Inc(FSize, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBufferedStream.Flush;
|
procedure TBufferedStream.Flush;
|
||||||
|
@ -3502,6 +3412,16 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ExpandPath(const AFileName: string): String;
|
||||||
|
begin
|
||||||
|
if AFileName = '' then
|
||||||
|
Result := ''
|
||||||
|
else if Pos(':', AFileName) > 0 then
|
||||||
|
Result := AFileName
|
||||||
|
else
|
||||||
|
Result := ExtractFilePath(GetModuleName) + AFileName;
|
||||||
|
end;
|
||||||
|
|
||||||
function Exec(Executable, CommandLine, WorkDir: string): Boolean;
|
function Exec(Executable, CommandLine, WorkDir: string): Boolean;
|
||||||
var
|
var
|
||||||
StartupInfo: TStartupInfo;
|
StartupInfo: TStartupInfo;
|
||||||
|
|
|
@ -3,7 +3,7 @@ unit LZ4DLL;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LibImport,
|
Utils, LibImport,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils, System.Math;
|
System.SysUtils, System.Math;
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ var
|
||||||
|
|
||||||
procedure Init(Filename: String);
|
procedure Init(Filename: String);
|
||||||
begin
|
begin
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
Lib := TLibImport.Create(ExpandPath(Filename));
|
||||||
if Lib.Loaded then
|
if Lib.Loaded then
|
||||||
begin
|
begin
|
||||||
@LZ4_decompress_safe := Lib.GetProcAddr('LZ4_decompress_safe');
|
@LZ4_decompress_safe := Lib.GetProcAddr('LZ4_decompress_safe');
|
||||||
|
@ -311,7 +311,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
DLLParam = '--lz4=';
|
DLLParam1 = '--lz4=';
|
||||||
|
DLLParam2 = '-l4';
|
||||||
|
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
@ -321,11 +322,18 @@ initialization
|
||||||
|
|
||||||
DLLFile := 'liblz4.dll';
|
DLLFile := 'liblz4.dll';
|
||||||
for I := 1 to ParamCount do
|
for I := 1 to ParamCount do
|
||||||
if ParamStr(I).StartsWith(DLLParam) then
|
|
||||||
begin
|
begin
|
||||||
DLLFile := ParamStr(I).Substring(DLLParam.Length);
|
if ParamStr(I).StartsWith(DLLParam1) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam1.Length);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
if ParamStr(I).StartsWith(DLLParam2) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam2.Length);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Init(DLLFile);
|
Init(DLLFile);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ unit LZODLL;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LibImport,
|
Utils, LibImport,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils;
|
System.SysUtils;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ var
|
||||||
|
|
||||||
procedure Init(Filename: String);
|
procedure Init(Filename: String);
|
||||||
begin
|
begin
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
Lib := TLibImport.Create(ExpandPath(Filename));
|
||||||
if Lib.Loaded then
|
if Lib.Loaded then
|
||||||
begin
|
begin
|
||||||
@lzo1x_1_compress := Lib.GetProcAddr('lzo1x_1_compress');
|
@lzo1x_1_compress := Lib.GetProcAddr('lzo1x_1_compress');
|
||||||
|
@ -94,7 +94,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
DLLParam = '--lzo=';
|
DLLParam1 = '-lzo=';
|
||||||
|
DLLParam2 = '-lo';
|
||||||
|
|
||||||
var
|
var
|
||||||
I: integer;
|
I: integer;
|
||||||
|
@ -104,11 +105,19 @@ initialization
|
||||||
|
|
||||||
DLLFile := 'lzo2.dll';
|
DLLFile := 'lzo2.dll';
|
||||||
for I := 1 to ParamCount do
|
for I := 1 to ParamCount do
|
||||||
if ParamStr(I).StartsWith(DLLParam) then
|
|
||||||
begin
|
begin
|
||||||
DLLFile := ParamStr(I).Substring(DLLParam.Length);
|
if ParamStr(I).StartsWith(DLLParam1) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam1.Length);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
if ParamStr(I).StartsWith(DLLParam2) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam2.Length);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Init(DLLFile);
|
Init(DLLFile);
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
|
|
@ -3,7 +3,7 @@ unit OodleDLL;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LibImport,
|
Utils, LibImport,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils, System.Types, System.IOUtils;
|
System.SysUtils, System.Types, System.IOUtils;
|
||||||
|
|
||||||
|
@ -82,13 +82,13 @@ var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
C: Cardinal;
|
C: Cardinal;
|
||||||
begin
|
begin
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
Lib := TLibImport.Create(ExpandPath(Filename));
|
||||||
if not Lib.Loaded then
|
if not Lib.Loaded then
|
||||||
for I := 3 to 9 do
|
for I := 1 to 9 do
|
||||||
begin
|
begin
|
||||||
Lib.Free;
|
Lib.Free;
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'oo2core_' +
|
Lib := TLibImport.Create(ExpandPath('oo2core_' + I.ToString +
|
||||||
I.ToString + '_win64.dll');
|
'_win64.dll'));
|
||||||
if Lib.Loaded then
|
if Lib.Loaded then
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
@ -96,8 +96,8 @@ begin
|
||||||
for I := 3 to 9 do
|
for I := 3 to 9 do
|
||||||
begin
|
begin
|
||||||
Lib.Free;
|
Lib.Free;
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'oo2ext_' +
|
Lib := TLibImport.Create(ExpandPath('oo2ext_' + I.ToString +
|
||||||
I.ToString + '_win64.dll');
|
'_win64.dll'));
|
||||||
if Lib.Loaded then
|
if Lib.Loaded then
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
@ -202,7 +202,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
DLLParam = '--oodle=';
|
DLLParam1 = '--oodle=';
|
||||||
|
DLLParam2 = '-od';
|
||||||
|
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
@ -212,11 +213,18 @@ initialization
|
||||||
|
|
||||||
DLLFile := 'oo2core_9_win64.dll';
|
DLLFile := 'oo2core_9_win64.dll';
|
||||||
for I := 1 to ParamCount do
|
for I := 1 to ParamCount do
|
||||||
if ParamStr(I).StartsWith(DLLParam) then
|
|
||||||
begin
|
begin
|
||||||
DLLFile := ParamStr(I).Substring(DLLParam.Length);
|
if ParamStr(I).StartsWith(DLLParam1) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam1.Length);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
if ParamStr(I).StartsWith(DLLParam2) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam2.Length);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
Init(DLLFile);
|
Init(DLLFile);
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
|
|
@ -3,7 +3,7 @@ unit ZLibDLL;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LibImport,
|
Utils, LibImport,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils, System.Types, System.IOUtils, System.ZLib;
|
System.SysUtils, System.Types, System.IOUtils, System.ZLib;
|
||||||
|
|
||||||
|
@ -148,16 +148,16 @@ end;
|
||||||
|
|
||||||
procedure Init(Filename: String);
|
procedure Init(Filename: String);
|
||||||
begin
|
begin
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
Lib := TLibImport.Create(ExpandPath(Filename));
|
||||||
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
|
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
|
||||||
begin
|
begin
|
||||||
Lib.Free;
|
Lib.Free;
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'zlibwapi.dll');
|
Lib := TLibImport.Create(ExpandPath('zlibwapi.dll'));
|
||||||
end;
|
end;
|
||||||
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
|
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
|
||||||
begin
|
begin
|
||||||
Lib.Free;
|
Lib.Free;
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'zlib1.dll');
|
Lib := TLibImport.Create(ExpandPath('zlib1.dll'));
|
||||||
end;
|
end;
|
||||||
if Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion')) then
|
if Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion')) then
|
||||||
begin
|
begin
|
||||||
|
@ -192,7 +192,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
DLLParam = '--zlib=';
|
DLLParam1 = '--zlib=';
|
||||||
|
DLLParam2 = '-zb';
|
||||||
|
|
||||||
var
|
var
|
||||||
I: integer;
|
I: integer;
|
||||||
|
@ -202,11 +203,18 @@ initialization
|
||||||
|
|
||||||
DLLFile := 'zlibwapi.dll';
|
DLLFile := 'zlibwapi.dll';
|
||||||
for I := 1 to ParamCount do
|
for I := 1 to ParamCount do
|
||||||
if ParamStr(I).StartsWith(DLLParam) then
|
|
||||||
begin
|
begin
|
||||||
DLLFile := ParamStr(I).Substring(DLLParam.Length);
|
if ParamStr(I).StartsWith(DLLParam1) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam1.Length);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
if ParamStr(I).StartsWith(DLLParam2) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam2.Length);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Init(DLLFile);
|
Init(DLLFile);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ unit ZSTDDLL;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LibImport,
|
Utils, LibImport,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils;
|
System.SysUtils;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ var
|
||||||
|
|
||||||
procedure Init(Filename: String);
|
procedure Init(Filename: String);
|
||||||
begin
|
begin
|
||||||
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Filename);
|
Lib := TLibImport.Create(ExpandPath(Filename));
|
||||||
if Lib.Loaded then
|
if Lib.Loaded then
|
||||||
begin
|
begin
|
||||||
@ZSTD_compress := Lib.GetProcAddr('ZSTD_compress');
|
@ZSTD_compress := Lib.GetProcAddr('ZSTD_compress');
|
||||||
|
@ -185,7 +185,8 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
DLLParam = '--zstd=';
|
DLLParam1 = '--zstd=';
|
||||||
|
DLLParam2 = '-zs';
|
||||||
|
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
@ -195,11 +196,19 @@ initialization
|
||||||
|
|
||||||
DLLFile := 'libzstd.dll';
|
DLLFile := 'libzstd.dll';
|
||||||
for I := 1 to ParamCount do
|
for I := 1 to ParamCount do
|
||||||
if ParamStr(I).StartsWith(DLLParam) then
|
|
||||||
begin
|
begin
|
||||||
DLLFile := ParamStr(I).Substring(DLLParam.Length);
|
if ParamStr(I).StartsWith(DLLParam1) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam1.Length);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
if ParamStr(I).StartsWith(DLLParam2) then
|
||||||
|
begin
|
||||||
|
DLLFile := ParamStr(I).Substring(DLLParam2.Length);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
Init(DLLFile);
|
Init(DLLFile);
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
|
|
@ -4,6 +4,7 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Utils,
|
Utils,
|
||||||
|
UIMain,
|
||||||
PrecompUtils,
|
PrecompUtils,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils, System.Classes, System.StrUtils,
|
System.SysUtils, System.Classes, System.StrUtils,
|
||||||
|
@ -375,6 +376,9 @@ begin
|
||||||
@DLLStruct^.Scan2 := GetProcAddress(DLLHandle, 'PrecompScan2');
|
@DLLStruct^.Scan2 := GetProcAddress(DLLHandle, 'PrecompScan2');
|
||||||
@DLLStruct^.Process := GetProcAddress(DLLHandle, 'PrecompProcess');
|
@DLLStruct^.Process := GetProcAddress(DLLHandle, 'PrecompProcess');
|
||||||
@DLLStruct^.Restore := GetProcAddress(DLLHandle, 'PrecompRestore');
|
@DLLStruct^.Restore := GetProcAddress(DLLHandle, 'PrecompRestore');
|
||||||
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddplugin(ChangeFileExt(ExtractFileName(DLLList[I]), ''),
|
||||||
|
PLUGIN_LIBRARY);
|
||||||
Insert(DLLStruct^, CodecDLL, Length(CodecDLL));
|
Insert(DLLStruct^, CodecDLL, Length(CodecDLL));
|
||||||
J := 0;
|
J := 0;
|
||||||
while Assigned(CodecDLL[Pred(Length(CodecDLL))].Codec(J)) do
|
while Assigned(CodecDLL[Pred(Length(CodecDLL))].Codec(J)) do
|
||||||
|
@ -383,6 +387,8 @@ begin
|
||||||
Insert(S, CodecDLL[Pred(Length(CodecDLL))].Names,
|
Insert(S, CodecDLL[Pred(Length(CodecDLL))].Names,
|
||||||
Length(CodecDLL[Pred(Length(CodecDLL))].Names));
|
Length(CodecDLL[Pred(Length(CodecDLL))].Names));
|
||||||
Insert(S, Codec.Names, Length(Codec.Names));
|
Insert(S, Codec.Names, Length(Codec.Names));
|
||||||
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddCodec(S);
|
||||||
Inc(J);
|
Inc(J);
|
||||||
end;
|
end;
|
||||||
if J = 0 then
|
if J = 0 then
|
||||||
|
@ -392,6 +398,8 @@ begin
|
||||||
Length(CodecDLL[Pred(Length(CodecDLL))].Names));
|
Length(CodecDLL[Pred(Length(CodecDLL))].Names));
|
||||||
Insert(ChangeFileExt(ExtractFileName(DLLList[I]), ''), Codec.Names,
|
Insert(ChangeFileExt(ExtractFileName(DLLList[I]), ''), Codec.Names,
|
||||||
Length(Codec.Names));
|
Length(Codec.Names));
|
||||||
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddCodec(ChangeFileExt(ExtractFileName(DLLList[I]), ''));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -4,6 +4,7 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Utils, ParseExpr,
|
Utils, ParseExpr,
|
||||||
|
UIMain,
|
||||||
PrecompUtils,
|
PrecompUtils,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils, System.Classes, System.StrUtils,
|
System.SysUtils, System.Classes, System.StrUtils,
|
||||||
|
@ -136,7 +137,7 @@ begin
|
||||||
if CompareText(S, Codec.Names[Y]) = 0 then
|
if CompareText(S, Codec.Names[Y]) = 0 then
|
||||||
begin
|
begin
|
||||||
for I := Low(CodecEnabled[Y]) to High(CodecEnabled[Y]) do
|
for I := Low(CodecEnabled[Y]) to High(CodecEnabled[Y]) do
|
||||||
CodecEnabled[Y][I] := True;
|
CodecEnabled[Y, I] := True;
|
||||||
for Z := Low(CodecCfg[0, Y]) to High(CodecCfg[0, Y]) do
|
for Z := Low(CodecCfg[0, Y]) to High(CodecCfg[0, Y]) do
|
||||||
if Funcs^.GetParam(Command, X, PChar(CodecCfg[0, Y, Z].Name)) <> ''
|
if Funcs^.GetParam(Command, X, PChar(CodecCfg[0, Y, Z].Name)) <> ''
|
||||||
then
|
then
|
||||||
|
@ -144,7 +145,7 @@ begin
|
||||||
if not ParamsSet then
|
if not ParamsSet then
|
||||||
begin
|
begin
|
||||||
for I := Low(CodecEnabled[Y]) to High(CodecEnabled[Y]) do
|
for I := Low(CodecEnabled[Y]) to High(CodecEnabled[Y]) do
|
||||||
CodecEnabled[Y][I] := False;
|
CodecEnabled[Y, I] := False;
|
||||||
ParamsSet := True;
|
ParamsSet := True;
|
||||||
end;
|
end;
|
||||||
CodecEnabled[Y, Z] := True;
|
CodecEnabled[Y, Z] := True;
|
||||||
|
@ -292,11 +293,13 @@ begin
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
for Y := Low(Conditions) to High(Conditions) do
|
for Y := Low(Conditions) to High(Conditions) do
|
||||||
|
begin
|
||||||
if Round(Parser.Evaluate(Conditions[Y])) = 0 then
|
if Round(Parser.Evaluate(Conditions[Y])) = 0 then
|
||||||
begin
|
begin
|
||||||
Status := TScanStatus.Fail;
|
Status := TScanStatus.Fail;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
if Status = TScanStatus.None then
|
if Status = TScanStatus.None then
|
||||||
begin
|
begin
|
||||||
Output(Instance, nil, -1);
|
Output(Instance, nil, -1);
|
||||||
|
@ -362,7 +365,7 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
I, J, X, Y: Integer;
|
I, J, K, X, Y: Integer;
|
||||||
SL: TStringList;
|
SL: TStringList;
|
||||||
Bytes: TBytes;
|
Bytes: TBytes;
|
||||||
S1, S2: String;
|
S1, S2: String;
|
||||||
|
@ -373,8 +376,6 @@ var
|
||||||
CfgRecArray: PCfgRecDynArray;
|
CfgRecArray: PCfgRecDynArray;
|
||||||
CfgStruct: PCfgStruct;
|
CfgStruct: PCfgStruct;
|
||||||
SList: TStringDynArray;
|
SList: TStringDynArray;
|
||||||
PStr1: PAnsiChar;
|
|
||||||
PStr2: PString;
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
|
@ -390,13 +391,20 @@ begin
|
||||||
begin
|
begin
|
||||||
S1 := ChangeFileExt(ExtractFileName(CfgList[I]), '');
|
S1 := ChangeFileExt(ExtractFileName(CfgList[I]), '');
|
||||||
Insert(S1, Codec.Names, Length(Codec.Names));
|
Insert(S1, Codec.Names, Length(Codec.Names));
|
||||||
New(CfgRecArray);
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddplugin(S1, PLUGIN_CONFIG);
|
||||||
|
SetLength(CodecCfg[0], Succ(Length(CodecCfg[0])));
|
||||||
|
CfgRecArray := @CodecCfg[0, Pred(Length(CodecCfg[0]))];
|
||||||
X := 1;
|
X := 1;
|
||||||
while ReadString('Stream' + X.ToString, 'Name', '') <> '' do
|
while ReadString('Stream' + X.ToString, 'Name', '') <> '' do
|
||||||
begin
|
begin
|
||||||
New(CfgRec);
|
J := Length(CodecCfg[0, Pred(Length(CodecCfg[0]))]);
|
||||||
|
SetLength(CodecCfg[0, Pred(Length(CodecCfg[0]))], Succ(J));
|
||||||
|
CfgRec := @CodecCfg[0, Pred(Length(CodecCfg[0])), J];
|
||||||
CfgRec^.Parser := TExpressionParser.Create;
|
CfgRec^.Parser := TExpressionParser.Create;
|
||||||
CfgRec^.Name := ReadString('Stream' + X.ToString, 'Name', '');
|
CfgRec^.Name := ReadString('Stream' + X.ToString, 'Name', '');
|
||||||
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddCodec(CfgRec^.Name);
|
||||||
CfgRec^.Codec := ReadString('Stream' + X.ToString, 'Codec', '');
|
CfgRec^.Codec := ReadString('Stream' + X.ToString, 'Codec', '');
|
||||||
CfgRec^.BigEndian := ReadBool('Stream' + X.ToString,
|
CfgRec^.BigEndian := ReadBool('Stream' + X.ToString,
|
||||||
'BigEndian', False);
|
'BigEndian', False);
|
||||||
|
@ -406,7 +414,11 @@ begin
|
||||||
BStream := True;
|
BStream := True;
|
||||||
for Y := Low(SList) to High(SList) do
|
for Y := Low(SList) to High(SList) do
|
||||||
begin
|
begin
|
||||||
New(CfgStruct);
|
K := Length(CodecCfg[0, Pred(Length(CodecCfg[0])), J].Structure);
|
||||||
|
SetLength(CodecCfg[0, Pred(Length(CodecCfg[0])),
|
||||||
|
J].Structure, Succ(K));
|
||||||
|
CfgStruct := @CodecCfg[0, Pred(Length(CodecCfg[0])), J]
|
||||||
|
.Structure[K];
|
||||||
DecodeHeader(SList[Y], S1, S2);
|
DecodeHeader(SList[Y], S1, S2);
|
||||||
ConvertHexChr(S2);
|
ConvertHexChr(S2);
|
||||||
CfgStruct^.Name := S1;
|
CfgStruct^.Name := S1;
|
||||||
|
@ -422,6 +434,8 @@ begin
|
||||||
if HexValue then
|
if HexValue then
|
||||||
begin
|
begin
|
||||||
S1 := S1.Substring(1);
|
S1 := S1.Substring(1);
|
||||||
|
while S1.Length < (CfgStruct^.Size * 2) do
|
||||||
|
S1.Insert(0, '0');
|
||||||
SetLength(Bytes, CfgStruct^.Size);
|
SetLength(Bytes, CfgStruct^.Size);
|
||||||
SetLength(Bytes, HexToBin(BytesOf(S1), 0, Bytes, 0,
|
SetLength(Bytes, HexToBin(BytesOf(S1), 0, Bytes, 0,
|
||||||
Length(Bytes)));
|
Length(Bytes)));
|
||||||
|
@ -437,8 +451,6 @@ begin
|
||||||
CfgStruct^.Position := Pos;
|
CfgStruct^.Position := Pos;
|
||||||
CfgStruct^.Value := 0;
|
CfgStruct^.Value := 0;
|
||||||
CfgStruct^.BeforeStream := BStream;
|
CfgStruct^.BeforeStream := BStream;
|
||||||
if (CfgStruct^.Name = 'Stream') or (CfgStruct^.Size > 0) then
|
|
||||||
Insert(CfgStruct^, CfgRec^.Structure, Length(CfgRec^.Structure));
|
|
||||||
Inc(Pos, CfgStruct^.Size);
|
Inc(Pos, CfgStruct^.Size);
|
||||||
if CfgStruct^.Name = 'Stream' then
|
if CfgStruct^.Name = 'Stream' then
|
||||||
begin
|
begin
|
||||||
|
@ -462,11 +474,10 @@ begin
|
||||||
while ReadString('Stream' + X.ToString, 'Condition' + Y.ToString,
|
while ReadString('Stream' + X.ToString, 'Condition' + Y.ToString,
|
||||||
'') <> '' do
|
'') <> '' do
|
||||||
begin
|
begin
|
||||||
New(PStr2);
|
S2 := ReadString('Stream' + X.ToString,
|
||||||
PStr2^ := ReadString('Stream' + X.ToString,
|
|
||||||
'Condition' + Y.ToString, '');
|
'Condition' + Y.ToString, '');
|
||||||
ConvertHexChr(PStr2^);
|
ConvertHexChr(S2);
|
||||||
Insert(PStr2^, CfgRec^.Conditions, Length(CfgRec^.Conditions));
|
Insert(S2, CfgRec^.Conditions, Length(CfgRec^.Conditions));
|
||||||
Inc(Y);
|
Inc(Y);
|
||||||
end;
|
end;
|
||||||
ReadSectionValues('Stream' + X.ToString, SL);
|
ReadSectionValues('Stream' + X.ToString, SL);
|
||||||
|
@ -489,10 +500,8 @@ begin
|
||||||
CfgRec^.Exprs[J] := S2;
|
CfgRec^.Exprs[J] := S2;
|
||||||
CfgRec^.Values[J] := 0;
|
CfgRec^.Values[J] := 0;
|
||||||
end;
|
end;
|
||||||
Insert(CfgRec^, CfgRecArray^, Length(CfgRecArray^));
|
|
||||||
Inc(X);
|
Inc(X);
|
||||||
end;
|
end;
|
||||||
Insert(CfgRecArray^, CodecCfg[0], Length(CodecCfg[0]));
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Free;
|
Free;
|
||||||
|
@ -504,10 +513,10 @@ for J := Low(CodecCfg[0]) to High(CodecCfg[0]) do
|
||||||
begin
|
begin
|
||||||
with CodecCfg[0, J, X] do
|
with CodecCfg[0, J, X] do
|
||||||
begin
|
begin
|
||||||
for Y := Low(Names) to High(Names) do
|
|
||||||
Parser.DefineVariable(Names[Y], @Values[Y]);
|
|
||||||
for Y := Low(Structure) to High(Structure) do
|
for Y := Low(Structure) to High(Structure) do
|
||||||
Parser.DefineVariable(Structure[Y].Name, @Structure[Y].Value);
|
Parser.DefineVariable(Structure[Y].Name, @Structure[Y].Value);
|
||||||
|
for Y := Low(Names) to High(Names) do
|
||||||
|
Parser.DefineVariable(Names[Y], @Values[Y]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,707 @@
|
||||||
|
unit PrecompINIEx;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Utils, ParseExpr,
|
||||||
|
UIMain,
|
||||||
|
PrecompUtils,
|
||||||
|
WinAPI.Windows,
|
||||||
|
System.SysUtils, System.Classes, System.StrUtils,
|
||||||
|
System.Types, System.Math, System.IOUtils, System.IniFiles;
|
||||||
|
|
||||||
|
var
|
||||||
|
Codec: TPrecompressor;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
type
|
||||||
|
PCfgStruct = ^TCfgStruct;
|
||||||
|
|
||||||
|
TCfgStruct = record
|
||||||
|
Name: String;
|
||||||
|
Data: Pointer;
|
||||||
|
Position, Size: NativeInt;
|
||||||
|
Value: Double;
|
||||||
|
BeforeStream: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PCfgCounter = ^TCfgCounter;
|
||||||
|
|
||||||
|
TCfgCounter = record
|
||||||
|
StartS, EndS, StepS: String;
|
||||||
|
StartV, EndV, StepV: Double;
|
||||||
|
Current, Min, Max: Double;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PConfigRec = ^TConfigRec;
|
||||||
|
|
||||||
|
TConfigRec = record
|
||||||
|
Parser: TExpressionParser;
|
||||||
|
Name, Codec: String;
|
||||||
|
Resource: Integer;
|
||||||
|
BigEndian: Boolean;
|
||||||
|
Structure: array [0 .. 2] of TArray<TCfgStruct>;
|
||||||
|
Counter: TArray<TCfgCounter>;
|
||||||
|
StreamPosition, StreamOffset, OldSize, NewSize, DepthSize: String;
|
||||||
|
Names, Exprs: TArray<String>;
|
||||||
|
Values: TArray<Double>;
|
||||||
|
Conditions: TArray<String>;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PCfgRecDynArray = ^TCfgRecDynArray;
|
||||||
|
TCfgRecDynArray = TArray<TConfigRec>;
|
||||||
|
|
||||||
|
var
|
||||||
|
CfgList: TStringDynArray;
|
||||||
|
CodecCfg: TArray<TArray<TCfgRecDynArray>>;
|
||||||
|
CodecAvailable, CodecEnabled: TArray<TArray<Boolean>>;
|
||||||
|
|
||||||
|
procedure EndianMove(Source, Dest: Pointer; Size: NativeInt;
|
||||||
|
BigEndian: Boolean = False);
|
||||||
|
begin
|
||||||
|
if BigEndian then
|
||||||
|
ReverseBytes(Source, Dest, Size)
|
||||||
|
else
|
||||||
|
Move(Source^, Dest^, Size);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ConfigInit(Command: PChar; Count: Integer;
|
||||||
|
Funcs: PPrecompFuncs): Boolean;
|
||||||
|
var
|
||||||
|
I, J: Integer;
|
||||||
|
X, Y, Z: Integer;
|
||||||
|
S: String;
|
||||||
|
ParamsSet: Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
ParamsSet := False;
|
||||||
|
for X := Low(CodecAvailable) to High(CodecAvailable) do
|
||||||
|
for Y := Low(CodecAvailable[X]) to High(CodecAvailable[X]) do
|
||||||
|
begin
|
||||||
|
CodecAvailable[X, Y] := True;
|
||||||
|
CodecEnabled[X, Y] := False;
|
||||||
|
end;
|
||||||
|
SetLength(CodecCfg, Count);
|
||||||
|
for I := 1 to High(CodecCfg) do
|
||||||
|
begin
|
||||||
|
SetLength(CodecCfg[I], Length(CodecCfg[0]));
|
||||||
|
for J := Low(CodecCfg[I]) to High(CodecCfg[I]) do
|
||||||
|
SetLength(CodecCfg[I, J], Length(CodecCfg[0, J]));
|
||||||
|
end;
|
||||||
|
for I := Low(CodecCfg) to High(CodecCfg) do
|
||||||
|
for J := Low(CodecCfg[I]) to High(CodecCfg[I]) do
|
||||||
|
for X := Low(CodecCfg[I, J]) to High(CodecCfg[I, J]) do
|
||||||
|
with CodecCfg[I, J, X] do
|
||||||
|
begin
|
||||||
|
if I = 0 then
|
||||||
|
Resource := RegisterResources(Codec);
|
||||||
|
if I > 0 then
|
||||||
|
begin
|
||||||
|
Parser := TExpressionParser.Create;
|
||||||
|
Name := CodecCfg[0, J, X].Name;
|
||||||
|
Codec := CodecCfg[0, J, X].Codec;
|
||||||
|
Resource := CodecCfg[0, J, X].Resource;
|
||||||
|
BigEndian := CodecCfg[0, J, X].BigEndian;
|
||||||
|
for Z := Low(Structure) to High(Structure) do
|
||||||
|
begin
|
||||||
|
SetLength(Structure[Z], Length(CodecCfg[0, J, X].Structure[Z]));
|
||||||
|
for Y := Low(Structure[Z]) to High(Structure[Z]) do
|
||||||
|
begin
|
||||||
|
Structure[Z, Y].Name := CodecCfg[0, J, X].Structure[Z, Y].Name;
|
||||||
|
Structure[Z, Y].Position := CodecCfg[0, J, X].Structure[Z]
|
||||||
|
[Y].Position;
|
||||||
|
Structure[Z, Y].Size := CodecCfg[0, J, X].Structure[Z, Y].Size;
|
||||||
|
Structure[Z, Y].Value := CodecCfg[0, J, X].Structure
|
||||||
|
[Z, Y].Value;
|
||||||
|
Structure[Z, Y].BeforeStream := CodecCfg[0, J, X].Structure
|
||||||
|
[Z, Y].BeforeStream;
|
||||||
|
GetMem(Structure[Z, Y].Data, Structure[Z, Y].Size);
|
||||||
|
Move(CodecCfg[0, J, X].Structure[Z, Y].Data^,
|
||||||
|
Structure[Z, Y].Data^, Structure[Z, Y].Size);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
SetLength(Counter, Length(CodecCfg[0, J, X].Counter));
|
||||||
|
for Y := Low(Counter) to High(Counter) do
|
||||||
|
begin
|
||||||
|
Counter[Y].StartS := CodecCfg[0, J, X].Counter[Y].StartS;
|
||||||
|
Counter[Y].EndS := CodecCfg[0, J, X].Counter[Y].EndS;
|
||||||
|
Counter[Y].StepS := CodecCfg[0, J, X].Counter[Y].StepS;
|
||||||
|
Counter[Y].StartV := CodecCfg[0, J, X].Counter[Y].StartV;
|
||||||
|
Counter[Y].EndV := CodecCfg[0, J, X].Counter[Y].EndV;
|
||||||
|
Counter[Y].StepV := CodecCfg[0, J, X].Counter[Y].StepV;
|
||||||
|
Counter[Y].Current := CodecCfg[0, J, X].Counter[Y].Current;
|
||||||
|
Counter[Y].Min := CodecCfg[0, J, X].Counter[Y].Min;
|
||||||
|
Counter[Y].Max := CodecCfg[0, J, X].Counter[Y].Max;
|
||||||
|
end;
|
||||||
|
StreamPosition := CodecCfg[0, J, X].StreamPosition;
|
||||||
|
StreamOffset := CodecCfg[0, J, X].StreamOffset;
|
||||||
|
OldSize := CodecCfg[0, J, X].OldSize;
|
||||||
|
NewSize := CodecCfg[0, J, X].NewSize;
|
||||||
|
DepthSize := CodecCfg[0, J, X].DepthSize;
|
||||||
|
SetLength(Names, Length(CodecCfg[0, J, X].Names));
|
||||||
|
SetLength(Exprs, Length(CodecCfg[0, J, X].Exprs));
|
||||||
|
SetLength(Values, Length(CodecCfg[0, J, X].Values));
|
||||||
|
for Y := Low(Names) to High(Names) do
|
||||||
|
begin
|
||||||
|
Names[Y] := CodecCfg[0, J, X].Names[Y];
|
||||||
|
Exprs[Y] := CodecCfg[0, J, X].Exprs[Y];
|
||||||
|
Values[Y] := CodecCfg[0, J, X].Values[Y];
|
||||||
|
end;
|
||||||
|
SetLength(Conditions, Length(CodecCfg[0, J, X].Conditions));
|
||||||
|
for Y := Low(Conditions) to High(Conditions) do
|
||||||
|
Conditions[Y] := CodecCfg[0, J, X].Conditions[Y];
|
||||||
|
for Z := Low(Structure) to High(Structure) do
|
||||||
|
for Y := Low(Structure[Z]) to High(Structure[Z]) do
|
||||||
|
Parser.DefineVariable(Structure[Z, Y].Name,
|
||||||
|
@Structure[Z, Y].Value);
|
||||||
|
for Y := Low(Counter) to High(Counter) do
|
||||||
|
begin
|
||||||
|
Parser.DefineVariable('Counter' + Succ(Y).ToString,
|
||||||
|
@Counter[Y].Current);
|
||||||
|
Parser.DefineVariable('CounterMin' + Succ(Y).ToString,
|
||||||
|
@Counter[Y].Min);
|
||||||
|
Parser.DefineVariable('CounterMax' + Succ(Y).ToString,
|
||||||
|
@Counter[Y].Max);
|
||||||
|
end;
|
||||||
|
for Y := Low(Names) to High(Names) do
|
||||||
|
Parser.DefineVariable(Names[Y], @Values[Y]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
X := 0;
|
||||||
|
while Funcs^.GetCodec(Command, X, False) <> '' do
|
||||||
|
begin
|
||||||
|
S := Funcs^.GetCodec(Command, X, False);
|
||||||
|
for Y := Low(Codec.Names) to High(Codec.Names) do
|
||||||
|
if CompareText(S, Codec.Names[Y]) = 0 then
|
||||||
|
begin
|
||||||
|
for I := Low(CodecEnabled[Y]) to High(CodecEnabled[Y]) do
|
||||||
|
CodecEnabled[Y, I] := True;
|
||||||
|
for Z := Low(CodecCfg[0, Y]) to High(CodecCfg[0, Y]) do
|
||||||
|
if Funcs^.GetParam(Command, X, PChar(CodecCfg[0, Y, Z].Name)) <> ''
|
||||||
|
then
|
||||||
|
begin
|
||||||
|
if not ParamsSet then
|
||||||
|
begin
|
||||||
|
for I := Low(CodecEnabled[Y]) to High(CodecEnabled[Y]) do
|
||||||
|
CodecEnabled[Y, I] := False;
|
||||||
|
ParamsSet := True;
|
||||||
|
end;
|
||||||
|
CodecEnabled[Y, Z] := True;
|
||||||
|
end;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
Inc(X);
|
||||||
|
end;
|
||||||
|
for X := Low(CodecEnabled) to High(CodecEnabled) do
|
||||||
|
for Y := Low(CodecEnabled[X]) to High(CodecEnabled[X]) do
|
||||||
|
if CodecEnabled[X, Y] then
|
||||||
|
AddMethod(PrecompGetCodec(PChar(CodecCfg[0, X, Y].Codec), 0, False));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ConfigFree(Funcs: PPrecompFuncs);
|
||||||
|
var
|
||||||
|
I, J: Integer;
|
||||||
|
X, Y, Z: Integer;
|
||||||
|
begin
|
||||||
|
for I := Low(CodecCfg) to High(CodecCfg) do
|
||||||
|
for J := Low(CodecCfg[I]) to High(CodecCfg[I]) do
|
||||||
|
for X := Low(CodecCfg[I, J]) to High(CodecCfg[I, J]) do
|
||||||
|
with CodecCfg[I, J, X] do
|
||||||
|
begin
|
||||||
|
if I > 0 then
|
||||||
|
begin
|
||||||
|
for Z := Low(Structure) to High(Structure) do
|
||||||
|
for Y := Low(Structure[Z]) to High(Structure[Z]) do
|
||||||
|
FreeMem(Structure[Z, Y].Data);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ConfigParse(Command: String; Option: PInteger;
|
||||||
|
Funcs: PPrecompFuncs): Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ConfigScan1(Instance, Depth: Integer; Input: PByte;
|
||||||
|
Size, SizeEx: NativeInt; Output: _PrecompOutput; Add: _PrecompAdd;
|
||||||
|
Funcs: PPrecompFuncs);
|
||||||
|
type
|
||||||
|
TScanStatus = (None, Success, Fail);
|
||||||
|
var
|
||||||
|
Status: TScanStatus;
|
||||||
|
A, B: Integer;
|
||||||
|
I, J: Integer;
|
||||||
|
X, Y: Integer;
|
||||||
|
Pos: NativeInt;
|
||||||
|
NI: NativeInt;
|
||||||
|
I64: Int64;
|
||||||
|
LoopPosInt, StreamPosInt1, StreamPosInt2, StreamOffsetInt, OldSizeInt,
|
||||||
|
NewSizeInt, DepthSizeInt: NativeInt;
|
||||||
|
LoopContinue: Boolean;
|
||||||
|
SI: _StrInfo1;
|
||||||
|
DI: TDepthInfo;
|
||||||
|
DS: TPrecompStr;
|
||||||
|
|
||||||
|
procedure UpdateCounters(var C: TConfigRec);
|
||||||
|
var
|
||||||
|
Z: Integer;
|
||||||
|
begin
|
||||||
|
with C do
|
||||||
|
for Z := Low(Counter) to High(Counter) do
|
||||||
|
begin
|
||||||
|
Counter[Z].StartV := Parser.Evaluate(Counter[Z].StartS);
|
||||||
|
Counter[Z].EndV := Parser.Evaluate(Counter[Z].EndS);
|
||||||
|
Counter[Z].StepV := Parser.Evaluate(Counter[Z].StepS);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CheckCounters(C: TConfigRec): Boolean;
|
||||||
|
var
|
||||||
|
Z: Integer;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
with C do
|
||||||
|
for Z := Low(Counter) to High(Counter) do
|
||||||
|
if not InRange(Round(Counter[Z].Current), Min(Round(Counter[Z].StartV),
|
||||||
|
Round(Counter[Z].EndV)), Max(Round(Counter[Z].StartV),
|
||||||
|
Round(Counter[Z].EndV))) then
|
||||||
|
Exit(False);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure DoAddStream(C: TConfigRec);
|
||||||
|
begin
|
||||||
|
with C do
|
||||||
|
begin
|
||||||
|
Output(Instance, nil, -1);
|
||||||
|
SI.Position := StreamPosInt1 + StreamOffsetInt;
|
||||||
|
SI.OldSize := OldSizeInt;
|
||||||
|
SI.NewSize := NewSizeInt;
|
||||||
|
SI.Resource := Resource;
|
||||||
|
SI.Option := 0;
|
||||||
|
if System.Pos(SPrecompSep2, Codec) > 0 then
|
||||||
|
SI.Status := TStreamStatus.Predicted
|
||||||
|
else
|
||||||
|
SI.Status := TStreamStatus.None;
|
||||||
|
DS := Funcs^.GetDepthCodec(PChar(Codec));
|
||||||
|
Move(DS[0], DI.Codec, SizeOf(DI.Codec));
|
||||||
|
DI.OldSize := NewSizeInt;
|
||||||
|
DI.NewSize := DepthSizeInt;
|
||||||
|
Add(Instance, @SI, PChar(Codec), @DI);
|
||||||
|
Status := TScanStatus.Success;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if Depth > 0 then
|
||||||
|
Exit;
|
||||||
|
for I := Low(CodecCfg[Instance]) to High(CodecCfg[Instance]) do
|
||||||
|
for J := Low(CodecCfg[Instance, I]) to High(CodecCfg[Instance, I]) do
|
||||||
|
if CodecEnabled[I, J] then
|
||||||
|
with CodecCfg[Instance, I, J] do
|
||||||
|
for X := Low(Structure[0]) to High(Structure[0]) do
|
||||||
|
if Structure[0, X].Name = 'Signature' then
|
||||||
|
begin
|
||||||
|
Pos := 0;
|
||||||
|
while BinarySearch(Input, Pos, Size, Structure[0, X].Data,
|
||||||
|
Structure[0, X].Size, Pos) do
|
||||||
|
begin
|
||||||
|
Status := TScanStatus.None;
|
||||||
|
LoopPosInt := Pos + Structure[0, X].Size;
|
||||||
|
for Y := Low(Structure[0]) to High(Structure[0]) do
|
||||||
|
begin
|
||||||
|
if (X <> Y) then
|
||||||
|
begin
|
||||||
|
NI := Structure[0, Y].Position - Structure[0, X].Position;
|
||||||
|
LoopPosInt := Pos + Structure[0, Y].Size + NI;
|
||||||
|
if InRange(Pos + NI, 0, SizeEx - Structure[0, Y].Size) then
|
||||||
|
begin
|
||||||
|
Move((Input + Pos + NI)^, Structure[0, Y].Data^,
|
||||||
|
Structure[0, Y].Size);
|
||||||
|
I64 := 0;
|
||||||
|
EndianMove(Structure[0, Y].Data, @I64,
|
||||||
|
Min(Structure[0, Y].Size, I64.Size), BigEndian);
|
||||||
|
Structure[0, Y].Value := I64.ToDouble;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Status := TScanStatus.Fail;
|
||||||
|
end;
|
||||||
|
if Status = TScanStatus.Fail then
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
if Status = TScanStatus.Fail then
|
||||||
|
begin
|
||||||
|
Inc(Pos);
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
|
UpdateCounters(CodecCfg[Instance, I, J]);
|
||||||
|
for Y := Low(Counter) to High(Counter) do
|
||||||
|
begin
|
||||||
|
Counter[Y].Current := Counter[Y].StartV;
|
||||||
|
Counter[Y].Min := Min(Counter[Y].StepV,
|
||||||
|
Counter[Y].EndV - Counter[Y].Current);
|
||||||
|
Counter[Y].Max := Max(Counter[Y].StepV,
|
||||||
|
Counter[Y].EndV - Counter[Y].Current);
|
||||||
|
end;
|
||||||
|
while CheckCounters(CodecCfg[Instance, I, J]) do
|
||||||
|
begin
|
||||||
|
Status := TScanStatus.None;
|
||||||
|
for Y := Low(Structure[1]) to High(Structure[1]) do
|
||||||
|
begin
|
||||||
|
if InRange(LoopPosInt, 0, SizeEx - Structure[1, Y].Size)
|
||||||
|
then
|
||||||
|
begin
|
||||||
|
Move((Input + LoopPosInt)^, Structure[1, Y].Data^,
|
||||||
|
Structure[1, Y].Size);
|
||||||
|
I64 := 0;
|
||||||
|
EndianMove(Structure[1, Y].Data, @I64,
|
||||||
|
Min(Structure[1, Y].Size, I64.Size), BigEndian);
|
||||||
|
Structure[1, Y].Value := I64.ToDouble;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Status := TScanStatus.Fail;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
Inc(LoopPosInt, Structure[1, Y].Size);
|
||||||
|
end;
|
||||||
|
if Status = TScanStatus.Fail then
|
||||||
|
break;
|
||||||
|
StreamPosInt1 := Pos + Round(Parser.Evaluate(StreamPosition));
|
||||||
|
StreamPosInt2 := StreamPosInt1;
|
||||||
|
for Y := Low(Structure[2]) to High(Structure[2]) do
|
||||||
|
begin
|
||||||
|
if (Structure[2, Y].BeforeStream = True) then
|
||||||
|
begin
|
||||||
|
if Structure[2, Y].Name = 'Stream' then
|
||||||
|
begin
|
||||||
|
StreamPosInt1 := StreamPosInt2;
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
|
Funcs^.ReadFuture(Instance, StreamPosInt2,
|
||||||
|
Structure[2, Y].Data, Structure[2, Y].Size);
|
||||||
|
I64 := 0;
|
||||||
|
EndianMove(Structure[2, Y].Data, @I64,
|
||||||
|
Min(Structure[2, Y].Size, I64.Size), BigEndian);
|
||||||
|
Structure[2, Y].Value := I64.ToDouble;
|
||||||
|
Inc(StreamPosInt2, Structure[2, Y].Size);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
for A := Low(Exprs) to High(Exprs) do
|
||||||
|
begin
|
||||||
|
for B := Low(Exprs) to High(Exprs) do
|
||||||
|
try
|
||||||
|
if A = B then
|
||||||
|
continue;
|
||||||
|
Values[B] := Parser.Evaluate(Exprs[B]);
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
try
|
||||||
|
Values[A] := Parser.Evaluate(Exprs[A]);
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
StreamOffsetInt := Round(Parser.Evaluate(StreamOffset));
|
||||||
|
OldSizeInt := Round(Parser.Evaluate(OldSize));
|
||||||
|
NewSizeInt := Round(Parser.Evaluate(NewSize));
|
||||||
|
DepthSizeInt := Round(Parser.Evaluate(DepthSize));
|
||||||
|
for Y := Low(Structure[2]) to High(Structure[2]) do
|
||||||
|
begin
|
||||||
|
if (Structure[2, Y].BeforeStream = False) then
|
||||||
|
begin
|
||||||
|
Funcs^.ReadFuture(Instance, StreamPosInt2 + OldSizeInt,
|
||||||
|
Structure[2, Y].Data, Structure[2, Y].Size);
|
||||||
|
I64 := 0;
|
||||||
|
EndianMove(Structure[2, Y].Data, @I64,
|
||||||
|
Min(Structure[2, Y].Size, I64.Size), BigEndian);
|
||||||
|
Structure[2, Y].Value := I64.ToDouble;
|
||||||
|
Inc(StreamPosInt2, Structure[2, Y].Size);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if Length(Conditions) = 0 then
|
||||||
|
DoAddStream(CodecCfg[Instance, I, J])
|
||||||
|
else
|
||||||
|
for Y := Low(Conditions) to High(Conditions) do
|
||||||
|
begin
|
||||||
|
if (Round(Parser.Evaluate(Conditions[Y])) <> 0) and
|
||||||
|
(Y = High(Conditions)) then
|
||||||
|
DoAddStream(CodecCfg[Instance, I, J])
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
UpdateCounters(CodecCfg[Instance, I, J]);
|
||||||
|
for Y := Low(Counter) to High(Counter) do
|
||||||
|
begin
|
||||||
|
Counter[Y].Current := Counter[Y].Current + Counter[Y].StepV;
|
||||||
|
Counter[Y].Min :=
|
||||||
|
Min(Counter[Y].StepV,
|
||||||
|
Counter[Y].EndV - Counter[Y].Current);
|
||||||
|
Counter[Y].Max :=
|
||||||
|
Max(Counter[Y].StepV,
|
||||||
|
Counter[Y].EndV - Counter[Y].Current);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Inc(Pos);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ConfigScan2(Instance, Depth: Integer; Input: Pointer; Size: NativeInt;
|
||||||
|
StreamInfo: PStrInfo2; Offset: PInteger; Output: _PrecompOutput;
|
||||||
|
Funcs: PPrecompFuncs): Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ConfigProcess(Instance, Depth: Integer; OldInput, NewInput: Pointer;
|
||||||
|
StreamInfo: PStrInfo2; Output: _PrecompOutput; Funcs: PPrecompFuncs): Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function ConfigRestore(Instance, Depth: Integer; Input, InputExt: Pointer;
|
||||||
|
StreamInfo: _StrInfo3; Output: _PrecompOutput; Funcs: PPrecompFuncs): Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure DecodeHeader(const Header: String; out Name, Value: String);
|
||||||
|
begin
|
||||||
|
if (Pos('(', Header) > 0) and (Pos(')', Header) > 0) then
|
||||||
|
begin
|
||||||
|
Name := ReplaceStr(Header.Substring(0, Header.IndexOf('(')), ' ', '');
|
||||||
|
Value := Header.Substring(Succ(Header.IndexOf('(')),
|
||||||
|
Header.IndexOf(')') - Succ(Header.IndexOf('(')));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Name := Header;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ConvertHexChr(var S: String);
|
||||||
|
begin
|
||||||
|
S := ReplaceStr(S, '0x', '$');
|
||||||
|
S := ReplaceStr(S, '#', '$');
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
I, J, K, X, Y, Z: Integer;
|
||||||
|
SL: TStringList;
|
||||||
|
Bytes: TBytes;
|
||||||
|
S1, S2, S3: String;
|
||||||
|
Pos: Integer;
|
||||||
|
BStream: Boolean;
|
||||||
|
HexValue: Boolean;
|
||||||
|
CfgRec: PConfigRec;
|
||||||
|
CfgRecArray: PCfgRecDynArray;
|
||||||
|
CfgStruct: PCfgStruct;
|
||||||
|
CfgCounter: PCfgCounter;
|
||||||
|
SList: TStringDynArray;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
|
||||||
|
CfgList := TDirectory.GetFiles(ExtractFilePath(Utils.GetModuleName), '*.ini',
|
||||||
|
TSearchOption.soTopDirectoryOnly);
|
||||||
|
SL := TStringList.Create;
|
||||||
|
SetLength(CodecCfg, 1);
|
||||||
|
for I := Low(CfgList) to High(CfgList) do
|
||||||
|
begin
|
||||||
|
with TIniFile.Create(CfgList[I]) do
|
||||||
|
try
|
||||||
|
if ReadString('StreamList1', 'Name', '') <> '' then
|
||||||
|
begin
|
||||||
|
S1 := ChangeFileExt(ExtractFileName(CfgList[I]), '');
|
||||||
|
Insert(S1, Codec.Names, Length(Codec.Names));
|
||||||
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddplugin(S1, PLUGIN_CONFIG);
|
||||||
|
SetLength(CodecCfg[0], Succ(Length(CodecCfg[0])));
|
||||||
|
CfgRecArray := @CodecCfg[0, Pred(Length(CodecCfg[0]))];
|
||||||
|
X := 1;
|
||||||
|
while ReadString('StreamList' + X.ToString, 'Name', '') <> '' do
|
||||||
|
begin
|
||||||
|
J := Length(CodecCfg[0, Pred(Length(CodecCfg[0]))]);
|
||||||
|
SetLength(CodecCfg[0, Pred(Length(CodecCfg[0]))], Succ(J));
|
||||||
|
CfgRec := @CodecCfg[0, Pred(Length(CodecCfg[0])), J];
|
||||||
|
CfgRec^.Parser := TExpressionParser.Create;
|
||||||
|
CfgRec^.Name := ReadString('StreamList' + X.ToString, 'Name', '');
|
||||||
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddCodec(CfgRec^.Name);
|
||||||
|
CfgRec^.Codec := ReadString('StreamList' + X.ToString, 'Codec', '');
|
||||||
|
CfgRec^.BigEndian := ReadBool('StreamList' + X.ToString,
|
||||||
|
'BigEndian', False);
|
||||||
|
for Z := Low(CfgRec^.Structure) to High(CfgRec^.Structure) do
|
||||||
|
begin
|
||||||
|
case Z of
|
||||||
|
0:
|
||||||
|
S3 := 'Structure1';
|
||||||
|
1:
|
||||||
|
S3 := 'StructureN';
|
||||||
|
2:
|
||||||
|
S3 := 'StructureS';
|
||||||
|
end;
|
||||||
|
SList := DecodeStr(ReadString('StreamList' + X.ToString, S3,
|
||||||
|
''), ',');
|
||||||
|
Pos := 0;
|
||||||
|
BStream := True;
|
||||||
|
for Y := Low(SList) to High(SList) do
|
||||||
|
begin
|
||||||
|
K := Length(CodecCfg[0, Pred(Length(CodecCfg[0])),
|
||||||
|
J].Structure[Z]);
|
||||||
|
SetLength(CodecCfg[0, Pred(Length(CodecCfg[0])), J].Structure
|
||||||
|
[Z], Succ(K));
|
||||||
|
CfgStruct := @CodecCfg[0, Pred(Length(CodecCfg[0])), J]
|
||||||
|
.Structure[Z, K];
|
||||||
|
DecodeHeader(SList[Y], S1, S2);
|
||||||
|
ConvertHexChr(S2);
|
||||||
|
CfgStruct^.Name := S1;
|
||||||
|
CfgStruct^.Size :=
|
||||||
|
Round(IfThen(S2 <> '', CfgRec^.Parser.Evaluate(S2), 0));
|
||||||
|
GetMem(CfgStruct^.Data, CfgStruct^.Size);
|
||||||
|
if (Z = 0) and (CfgStruct^.Name = 'Signature') then
|
||||||
|
begin
|
||||||
|
S1 := ReplaceStr(ReadString('StreamList' + X.ToString,
|
||||||
|
'Signature', '0'), ' ', '');
|
||||||
|
ConvertHexChr(S1);
|
||||||
|
HexValue := S1[1] = '$';
|
||||||
|
if HexValue then
|
||||||
|
begin
|
||||||
|
S1 := S1.Substring(1);
|
||||||
|
while S1.Length < (CfgStruct^.Size * 2) do
|
||||||
|
S1.Insert(0, '0');
|
||||||
|
SetLength(Bytes, CfgStruct^.Size);
|
||||||
|
SetLength(Bytes, HexToBin(BytesOf(S1), 0, Bytes, 0,
|
||||||
|
Length(Bytes)));
|
||||||
|
ReverseBytes(@Bytes[0], CfgStruct^.Data, CfgStruct^.Size);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Bytes := BytesOf(S1);
|
||||||
|
SetLength(Bytes, CfgStruct^.Size);
|
||||||
|
Move(Bytes[0], CfgStruct^.Data^, CfgStruct^.Size);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
CfgStruct^.Position := Pos;
|
||||||
|
CfgStruct^.Value := 0;
|
||||||
|
CfgStruct^.BeforeStream := BStream;
|
||||||
|
Inc(Pos, CfgStruct^.Size);
|
||||||
|
if (Z = 2) and (CfgStruct^.Name = 'Stream') then
|
||||||
|
begin
|
||||||
|
Pos := 0;
|
||||||
|
BStream := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Y := 1;
|
||||||
|
while ReadString('StreamList' + X.ToString,
|
||||||
|
'CounterStart' + Y.ToString, '') <> '' do
|
||||||
|
begin
|
||||||
|
K := Length(CodecCfg[0, Pred(Length(CodecCfg[0])), J].Counter);
|
||||||
|
SetLength(CodecCfg[0, Pred(Length(CodecCfg[0])),
|
||||||
|
J].Counter, Succ(K));
|
||||||
|
CfgCounter := @CodecCfg[0, Pred(Length(CodecCfg[0])), J].Counter[K];
|
||||||
|
CfgCounter^.StartS := ReadString('StreamList' + X.ToString,
|
||||||
|
'CounterStart' + Y.ToString, '');
|
||||||
|
CfgCounter^.EndS := ReadString('StreamList' + X.ToString,
|
||||||
|
'CounterEnd' + Y.ToString, '');
|
||||||
|
CfgCounter^.StepS := ReadString('StreamList' + X.ToString,
|
||||||
|
'CounterStep' + Y.ToString, '');
|
||||||
|
CfgCounter^.StartV := 0;
|
||||||
|
CfgCounter^.EndV := 0;
|
||||||
|
CfgCounter^.StepV := 0;
|
||||||
|
CfgCounter^.Current := 0;
|
||||||
|
CfgCounter^.Min := 0;
|
||||||
|
CfgCounter^.Max := 0;
|
||||||
|
Inc(Y);
|
||||||
|
end;
|
||||||
|
CfgRec^.StreamPosition := ReadString('StreamList' + X.ToString,
|
||||||
|
'StreamPosition', '');
|
||||||
|
CfgRec^.StreamOffset := ReadString('StreamList' + X.ToString,
|
||||||
|
'StreamOffset', '0');
|
||||||
|
ConvertHexChr(CfgRec^.StreamOffset);
|
||||||
|
CfgRec^.OldSize := ReadString('StreamList' + X.ToString,
|
||||||
|
'CompressedSize', '0');
|
||||||
|
ConvertHexChr(CfgRec^.OldSize);
|
||||||
|
CfgRec^.NewSize := ReadString('StreamList' + X.ToString,
|
||||||
|
'DecompressedSize', '0');
|
||||||
|
ConvertHexChr(CfgRec^.NewSize);
|
||||||
|
CfgRec^.DepthSize := ReadString('StreamList' + X.ToString,
|
||||||
|
'DepthSize', '0');
|
||||||
|
ConvertHexChr(CfgRec^.DepthSize);
|
||||||
|
Y := 1;
|
||||||
|
while ReadString('StreamList' + X.ToString, 'Condition' + Y.ToString,
|
||||||
|
'') <> '' do
|
||||||
|
begin
|
||||||
|
S2 := ReadString('StreamList' + X.ToString,
|
||||||
|
'Condition' + Y.ToString, '');
|
||||||
|
ConvertHexChr(S2);
|
||||||
|
Insert(S2, CfgRec^.Conditions, Length(CfgRec^.Conditions));
|
||||||
|
Inc(Y);
|
||||||
|
end;
|
||||||
|
ReadSectionValues('StreamList' + X.ToString, SL);
|
||||||
|
for J := SL.Count - 1 downto 0 do
|
||||||
|
begin
|
||||||
|
S1 := SL[J].Substring(0, SL[J].IndexOf('=')).TrimRight;
|
||||||
|
S2 := SL[J].Substring(Succ(SL[J].IndexOf('='))).TrimLeft;
|
||||||
|
if (IndexText(S1, ['Name', 'Codec', 'BigEndian', 'Signature',
|
||||||
|
'Structure1', 'StructureN', 'StructureS']) >= 0) or
|
||||||
|
S1.StartsWith('Condition', True) or S1.StartsWith('CounterStart',
|
||||||
|
True) or S1.StartsWith('CounterEnd', True) or
|
||||||
|
S1.StartsWith('CounterStep', True) then
|
||||||
|
SL.Delete(J);
|
||||||
|
end;
|
||||||
|
SetLength(CfgRec^.Names, SL.Count);
|
||||||
|
SetLength(CfgRec^.Exprs, SL.Count);
|
||||||
|
SetLength(CfgRec^.Values, SL.Count);
|
||||||
|
for J := 0 to SL.Count - 1 do
|
||||||
|
begin
|
||||||
|
S1 := SL[J].Substring(0, SL[J].IndexOf('=')).TrimRight;
|
||||||
|
S2 := SL[J].Substring(Succ(SL[J].IndexOf('='))).TrimLeft;
|
||||||
|
CfgRec^.Names[J] := S1;
|
||||||
|
CfgRec^.Exprs[J] := S2;
|
||||||
|
CfgRec^.Values[J] := 0;
|
||||||
|
end;
|
||||||
|
Inc(X);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
for J := Low(CodecCfg[0]) to High(CodecCfg[0]) do
|
||||||
|
for X := Low(CodecCfg[0, J]) to High(CodecCfg[0, J]) do
|
||||||
|
begin
|
||||||
|
with CodecCfg[0, J, X] do
|
||||||
|
begin
|
||||||
|
for Z := Low(Structure) to High(Structure) do
|
||||||
|
for Y := Low(Structure[Z]) to High(Structure[Z]) do
|
||||||
|
Parser.DefineVariable(Structure[Z, Y].Name, @Structure[Z, Y].Value);
|
||||||
|
for Y := Low(Counter) to High(Counter) do
|
||||||
|
begin
|
||||||
|
Parser.DefineVariable('Counter' + Succ(Y).ToString,
|
||||||
|
@Counter[Y].Current);
|
||||||
|
Parser.DefineVariable('CounterMin' + Succ(Y).ToString, @Counter[Y].Min);
|
||||||
|
Parser.DefineVariable('CounterMax' + Succ(Y).ToString, @Counter[Y].Max);
|
||||||
|
end;
|
||||||
|
for Y := Low(Names) to High(Names) do
|
||||||
|
Parser.DefineVariable(Names[Y], @Values[Y]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Codec.Initialised := False;
|
||||||
|
Codec.Init := @ConfigInit;
|
||||||
|
Codec.Free := @ConfigFree;
|
||||||
|
Codec.Parse := @ConfigParse;
|
||||||
|
Codec.Scan1 := @ConfigScan1;
|
||||||
|
Codec.Scan2 := @ConfigScan2;
|
||||||
|
Codec.Process := @ConfigProcess;
|
||||||
|
Codec.Restore := @ConfigRestore;
|
||||||
|
SetLength(CodecAvailable, Length(CodecCfg[0]));
|
||||||
|
SetLength(CodecEnabled, Length(CodecCfg[0]));
|
||||||
|
for I := Low(CodecCfg[0]) to High(CodecCfg[0]) do
|
||||||
|
begin
|
||||||
|
SetLength(CodecAvailable[I], Length(CodecCfg[0, I]));
|
||||||
|
SetLength(CodecEnabled[I], Length(CodecCfg[0, I]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
|
@ -7,7 +7,8 @@ interface
|
||||||
uses
|
uses
|
||||||
Threading, Utils, SynCommons, ParseClass, ParseExpr, FLZMA2DLL,
|
Threading, Utils, SynCommons, ParseClass, ParseExpr, FLZMA2DLL,
|
||||||
PrecompUtils, PrecompCrypto, PrecompZLib, PrecompLZ4, PrecompLZO, PrecompZSTD,
|
PrecompUtils, PrecompCrypto, PrecompZLib, PrecompLZ4, PrecompLZO, PrecompZSTD,
|
||||||
PrecompOodle, PrecompMedia, PrecompINI, PrecompSearch, PrecompDLL, PrecompEXE,
|
PrecompOodle, PrecompMedia, PrecompINI, PrecompINIEx, PrecompSearch,
|
||||||
|
PrecompDLL, PrecompEXE,
|
||||||
WinAPI.Windows, WinAPI.ShlObj,
|
WinAPI.Windows, WinAPI.ShlObj,
|
||||||
System.SysUtils, System.Classes, System.SyncObjs, System.Math, System.Types,
|
System.SysUtils, System.Classes, System.SyncObjs, System.Math, System.Types,
|
||||||
System.StrUtils, System.RTLConsts, System.TimeSpan, System.Diagnostics,
|
System.StrUtils, System.RTLConsts, System.TimeSpan, System.Diagnostics,
|
||||||
|
@ -103,12 +104,15 @@ var
|
||||||
Codecs: array of TPrecompressor;
|
Codecs: array of TPrecompressor;
|
||||||
DBFile: String = '';
|
DBFile: String = '';
|
||||||
ExtDir: String = '';
|
ExtDir: String = '';
|
||||||
|
SrepMemCfg: String;
|
||||||
UseDB: Boolean = False;
|
UseDB: Boolean = False;
|
||||||
StoreDD: Integer = -2;
|
StoreDD: Integer = -2;
|
||||||
VERBOSE: Boolean = False;
|
VERBOSE: Boolean = False;
|
||||||
EXTRACT: Boolean = False;
|
EXTRACT: Boolean = False;
|
||||||
|
NOVERIFY: Boolean = False;
|
||||||
DupSysMem: Int64 = 0;
|
DupSysMem: Int64 = 0;
|
||||||
EncInfo: TEncInfo;
|
EncInfo: TEncInfo;
|
||||||
|
EncFreed: Boolean = False;
|
||||||
ConTask: TTask;
|
ConTask: TTask;
|
||||||
Stopwatch: TStopwatch;
|
Stopwatch: TStopwatch;
|
||||||
|
|
||||||
|
@ -186,18 +190,24 @@ begin
|
||||||
Options.Depth := EnsureRange(Succ(ArgParse.AsInteger('-d', 0, 0)), 1, 10);
|
Options.Depth := EnsureRange(Succ(ArgParse.AsInteger('-d', 0, 0)), 1, 10);
|
||||||
Options.LowMem := ArgParse.AsBoolean('-lm');
|
Options.LowMem := ArgParse.AsBoolean('-lm');
|
||||||
UseDB := ArgParse.AsBoolean('-db') or ArgParse.AsBoolean('--dbase');
|
UseDB := ArgParse.AsBoolean('-db') or ArgParse.AsBoolean('--dbase');
|
||||||
Options.DBaseFile := ArgParse.AsString('--dbase=');
|
Options.DBaseFile := ArgParse.AsString('--dbase=', 0, '');
|
||||||
|
Options.DBaseFile := ArgParse.AsString('-db', 0, Options.DBaseFile);
|
||||||
if Options.DBaseFile <> '' then
|
if Options.DBaseFile <> '' then
|
||||||
UseDB := True;
|
UseDB := True;
|
||||||
StoreDD := -2;
|
StoreDD := -2;
|
||||||
if ArgParse.AsBoolean('-dd') or ArgParse.AsBoolean('--dedup') then
|
if ArgParse.AsBoolean('-dd') or ArgParse.AsBoolean('--dedup') then
|
||||||
StoreDD := -1;
|
StoreDD := -1;
|
||||||
if FileExists(ExtractFilePath(Utils.GetModuleName) + 'srep.exe') then
|
if FileExists(ExtractFilePath(Utils.GetModuleName) + 'srep.exe') then
|
||||||
|
begin
|
||||||
StoreDD := ArgParse.AsInteger('--dedup=', 0, StoreDD);
|
StoreDD := ArgParse.AsInteger('--dedup=', 0, StoreDD);
|
||||||
|
StoreDD := ArgParse.AsInteger('-dd', 0, StoreDD);
|
||||||
|
end;
|
||||||
S := ArgParse.AsString('--diff=', 0, '5p');
|
S := ArgParse.AsString('--diff=', 0, '5p');
|
||||||
|
S := ArgParse.AsString('-df', 0, S);
|
||||||
S := ReplaceText(S, 'p', '%');
|
S := ReplaceText(S, 'p', '%');
|
||||||
DIFF_TOLERANCE := Max(0.00, ExpParse.Evaluate(S));
|
DIFF_TOLERANCE := Max(0.00, ExpParse.Evaluate(S));
|
||||||
VERBOSE := ArgParse.AsBoolean('-v') or ArgParse.AsBoolean('--verbose');
|
VERBOSE := ArgParse.AsBoolean('-v') or ArgParse.AsBoolean('--verbose');
|
||||||
|
NOVERIFY := ArgParse.AsBoolean('-s') or ArgParse.AsBoolean('--skip');
|
||||||
Options.ExtractDir := ArgParse.AsString('--extract=');
|
Options.ExtractDir := ArgParse.AsString('--extract=');
|
||||||
if Options.ExtractDir <> '' then
|
if Options.ExtractDir <> '' then
|
||||||
EXTRACT := DirectoryExists(Options.ExtractDir);
|
EXTRACT := DirectoryExists(Options.ExtractDir);
|
||||||
|
@ -244,10 +254,11 @@ begin
|
||||||
Options.DedupSysMem := Max(0, Round(ExpParse.Evaluate(S)));
|
Options.DedupSysMem := Max(0, Round(ExpParse.Evaluate(S)));
|
||||||
if B then
|
if B then
|
||||||
Options.DedupSysMem := -Options.DedupSysMem;
|
Options.DedupSysMem := -Options.DedupSysMem;
|
||||||
VERBOSE := ArgParse.AsBoolean('--verbose');
|
VERBOSE := ArgParse.AsBoolean('-v') or ArgParse.AsBoolean('--verbose');
|
||||||
S := ArgParse.AsString('--compress=', 0, 't50p');
|
S := ArgParse.AsString('--compress=', 0, 't25p');
|
||||||
S := ReplaceText(S, SPrecompSep3, SPrecompSep2);
|
S := ReplaceText(S, SPrecompSep3, SPrecompSep2);
|
||||||
Options.CompressCfg := S;
|
Options.CompressCfg := S;
|
||||||
|
SrepMemCfg := ArgParse.AsString('--srepmem=', 0, '75p');
|
||||||
finally
|
finally
|
||||||
ArgParse.Free;
|
ArgParse.Free;
|
||||||
ExpParse.Free;
|
ExpParse.Free;
|
||||||
|
@ -317,6 +328,7 @@ var
|
||||||
begin
|
begin
|
||||||
SetLength(Codecs, 0);
|
SetLength(Codecs, 0);
|
||||||
Insert(PrecompINI.Codec, Codecs, Length(Codecs));
|
Insert(PrecompINI.Codec, Codecs, Length(Codecs));
|
||||||
|
Insert(PrecompINIEx.Codec, Codecs, Length(Codecs));
|
||||||
Insert(PrecompSearch.Codec, Codecs, Length(Codecs));
|
Insert(PrecompSearch.Codec, Codecs, Length(Codecs));
|
||||||
Insert(PrecompDLL.Codec, Codecs, Length(Codecs));
|
Insert(PrecompDLL.Codec, Codecs, Length(Codecs));
|
||||||
Insert(PrecompEXE.Codec, Codecs, Length(Codecs));
|
Insert(PrecompEXE.Codec, Codecs, Length(Codecs));
|
||||||
|
@ -992,6 +1004,9 @@ begin
|
||||||
CurCodec[Index] := SI2.Codec;
|
CurCodec[Index] := SI2.Codec;
|
||||||
CurDepth[Index] := Depth;
|
CurDepth[Index] := Depth;
|
||||||
try
|
try
|
||||||
|
if NOVERIFY and not(SI2.Codec in [5]) then
|
||||||
|
Result := True
|
||||||
|
else
|
||||||
Result := Codecs[SI2.Codec].Process(Index, Depth,
|
Result := Codecs[SI2.Codec].Process(Index, Depth,
|
||||||
PByte(DataStore.Slot(ThreadIndex).Memory) + SI2.ActualPosition,
|
PByte(DataStore.Slot(ThreadIndex).Memory) + SI2.ActualPosition,
|
||||||
PByte(MemOutput1[ThreadIndex].Memory) + SI2.StorePosition, @SI1,
|
PByte(MemOutput1[ThreadIndex].Memory) + SI2.StorePosition, @SI1,
|
||||||
|
@ -1274,11 +1289,10 @@ begin
|
||||||
DataStore := TDataStore2.Create(Length(InfoStore1));
|
DataStore := TDataStore2.Create(Length(InfoStore1));
|
||||||
end;
|
end;
|
||||||
CodecInit(Options^.Threads, Options^.Method);
|
CodecInit(Options^.Threads, Options^.Method);
|
||||||
DBFile := Options^.DBaseFile;
|
DBFile := ExpandPath(Options^.DBaseFile);
|
||||||
if FileExists(ExtractFilePath(Utils.GetModuleName) + DBFile) then
|
if FileExists(DBFile) then
|
||||||
begin
|
begin
|
||||||
with TFileStream.Create(ExtractFilePath(Utils.GetModuleName) + DBFile,
|
with TFileStream.Create(DBFile, fmShareDenyNone) do
|
||||||
fmShareDenyNone) do
|
|
||||||
begin
|
begin
|
||||||
Position := 0;
|
Position := 0;
|
||||||
if WorkStream[0].Size < Size then
|
if WorkStream[0].Size < Size then
|
||||||
|
@ -1309,6 +1323,8 @@ begin
|
||||||
if (IndexText(PrecompGetCodec(PChar(Options^.Method), I, False),
|
if (IndexText(PrecompGetCodec(PChar(Options^.Method), I, False),
|
||||||
PrecompINI.Codec.Names) < 0) and
|
PrecompINI.Codec.Names) < 0) and
|
||||||
(IndexText(PrecompGetCodec(PChar(Options^.Method), I, False),
|
(IndexText(PrecompGetCodec(PChar(Options^.Method), I, False),
|
||||||
|
PrecompINIEx.Codec.Names) < 0) and
|
||||||
|
(IndexText(PrecompGetCodec(PChar(Options^.Method), I, False),
|
||||||
PrecompSearch.Codec.Names) < 0) then
|
PrecompSearch.Codec.Names) < 0) then
|
||||||
begin
|
begin
|
||||||
if S = '' then
|
if S = '' then
|
||||||
|
@ -1359,6 +1375,7 @@ var
|
||||||
UI32: UInt32;
|
UI32: UInt32;
|
||||||
I, J, K: Integer;
|
I, J, K: Integer;
|
||||||
begin
|
begin
|
||||||
|
EncFreed := True;
|
||||||
if Length(Tasks) > 1 then
|
if Length(Tasks) > 1 then
|
||||||
WaitForAll(Tasks);
|
WaitForAll(Tasks);
|
||||||
CodecFree(Length(Tasks));
|
CodecFree(Length(Tasks));
|
||||||
|
@ -1684,8 +1701,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
with TFileStream.Create(ExtractFilePath(Utils.GetModuleName) + DBFile,
|
with TFileStream.Create(DBFile, fmCreate) do
|
||||||
fmCreate) do
|
|
||||||
begin
|
begin
|
||||||
WriteBuffer(WorkStream[0].Memory^, WorkStream[0].Position);
|
WriteBuffer(WorkStream[0].Memory^, WorkStream[0].Position);
|
||||||
Free;
|
Free;
|
||||||
|
@ -1734,7 +1750,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Output.CopyFrom(TempOutput, 0);
|
Output.CopyFrom(TBufferedStream(TempOutput).Instance, 0);
|
||||||
TempOutput.Free;
|
TempOutput.Free;
|
||||||
DeleteFile(S);
|
DeleteFile(S);
|
||||||
end
|
end
|
||||||
|
@ -2098,7 +2114,8 @@ begin
|
||||||
if (Depth = 0) and (StoreDD >= 0) then
|
if (Depth = 0) and (StoreDD >= 0) then
|
||||||
begin
|
begin
|
||||||
LStream := TProcessStream.Create(ExtractFilePath(Utils.GetModuleName) +
|
LStream := TProcessStream.Create(ExtractFilePath(Utils.GetModuleName) +
|
||||||
'srep.exe', '-d -s - -', GetCurrentDir, Input, nil);
|
'srep.exe', '-d -s -mem' + SrepMemCfg + ' - -', GetCurrentDir,
|
||||||
|
Input, nil);
|
||||||
if not LStream.Execute then
|
if not LStream.Execute then
|
||||||
raise EReadError.CreateRes(@SReadError);
|
raise EReadError.CreateRes(@SReadError);
|
||||||
DecInput[Index] := TBufferedStream.Create(LStream, True, 4194304);
|
DecInput[Index] := TBufferedStream.Create(LStream, True, 4194304);
|
||||||
|
@ -2350,7 +2367,8 @@ begin
|
||||||
if Options.DoCompress then
|
if Options.DoCompress then
|
||||||
LOutput.Free;
|
LOutput.Free;
|
||||||
try
|
try
|
||||||
// EncFree;
|
if not EncFreed then
|
||||||
|
EncFree;
|
||||||
finally
|
finally
|
||||||
Stopwatch.Stop;
|
Stopwatch.Stop;
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -511,19 +511,30 @@ begin
|
||||||
if BoolArray(CodecEnabled, False) then
|
if BoolArray(CodecEnabled, False) then
|
||||||
exit;
|
exit;
|
||||||
Pos := 0;
|
Pos := 0;
|
||||||
|
while Pos < Size do
|
||||||
|
begin
|
||||||
|
try
|
||||||
while Pos < Size do
|
while Pos < Size do
|
||||||
begin
|
begin
|
||||||
GetOodleSI(Input + Pos, SizeEx - Pos, @OodleSI);
|
GetOodleSI(Input + Pos, SizeEx - Pos, @OodleSI);
|
||||||
if (OodleSI.CSize > 0) then
|
if (OodleSI.CSize > 0) then
|
||||||
begin
|
begin
|
||||||
if GetOodleUS(Instance, Input, Pos, @OodleSI, Output, Add, Funcs) > 0 then
|
try
|
||||||
|
if GetOodleUS(Instance, Input, Pos, @OodleSI, Output, Add, Funcs) > 0
|
||||||
|
then
|
||||||
begin
|
begin
|
||||||
Inc(Pos, OodleSI.CSize);
|
Inc(Pos, OodleSI.CSize);
|
||||||
continue;
|
continue;
|
||||||
end;
|
end;
|
||||||
|
except
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
Inc(Pos);
|
Inc(Pos);
|
||||||
end;
|
end;
|
||||||
|
except
|
||||||
|
Inc(Pos);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function OodleScan2(Instance, Depth: Integer; Input: Pointer; Size: cardinal;
|
function OodleScan2(Instance, Depth: Integer; Input: Pointer; Size: cardinal;
|
||||||
|
|
|
@ -4,6 +4,7 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Utils, SynCommons, SynCrypto,
|
Utils, SynCommons, SynCrypto,
|
||||||
|
UIMain,
|
||||||
PrecompUtils,
|
PrecompUtils,
|
||||||
WinAPI.Windows,
|
WinAPI.Windows,
|
||||||
System.SysUtils, System.Classes, System.StrUtils,
|
System.SysUtils, System.Classes, System.StrUtils,
|
||||||
|
@ -281,6 +282,8 @@ begin
|
||||||
SetLength(CodecSearch, Succ(J));
|
SetLength(CodecSearch, Succ(J));
|
||||||
S := ChangeFileExt(ExtractFileName(SearchList[I]), '');
|
S := ChangeFileExt(ExtractFileName(SearchList[I]), '');
|
||||||
Insert(S, Codec.Names, Length(Codec.Names));
|
Insert(S, Codec.Names, Length(Codec.Names));
|
||||||
|
if UIMain.DLLLoaded then
|
||||||
|
XTLAddplugin(S, PLUGIN_DATABASE);
|
||||||
end;
|
end;
|
||||||
while FStream.Position < FStream.Size do
|
while FStream.Position < FStream.Size do
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -444,6 +444,7 @@ begin
|
||||||
exit;
|
exit;
|
||||||
end
|
end
|
||||||
else if BoolArray(CodecEnabled, False) then
|
else if BoolArray(CodecEnabled, False) then
|
||||||
|
if Assigned(Add) then
|
||||||
exit;
|
exit;
|
||||||
Pos := 0;
|
Pos := 0;
|
||||||
Buffer := Funcs^.Allocator(Instance, Z_WORKMEM);
|
Buffer := Funcs^.Allocator(Instance, Z_WORKMEM);
|
||||||
|
@ -487,7 +488,7 @@ begin
|
||||||
(EndianSwap(PWord(Input + Pos - 2)^) mod $1F = 0) then
|
(EndianSwap(PWord(Input + Pos - 2)^) mod $1F = 0) then
|
||||||
begin
|
begin
|
||||||
WinBits := (Input + Pos - 2)^ shr 4;
|
WinBits := (Input + Pos - 2)^ shr 4;
|
||||||
if WinBits in [0 .. 7] then
|
if WinBits = ZWinBits then
|
||||||
begin
|
begin
|
||||||
ZStream := @ZStream2[Instance, WinBits];
|
ZStream := @ZStream2[Instance, WinBits];
|
||||||
Level := (Input + Pos - 1)^ shr $6;
|
Level := (Input + Pos - 1)^ shr $6;
|
||||||
|
@ -569,7 +570,8 @@ begin
|
||||||
if (I = ZLIB_CODEC) and (WinBits = 0) then
|
if (I = ZLIB_CODEC) and (WinBits = 0) then
|
||||||
SetBits(SI.Option, 1, 12, 3);
|
SetBits(SI.Option, 1, 12, 3);
|
||||||
SetBits(SI.Option, I, 0, 5);
|
SetBits(SI.Option, I, 0, 5);
|
||||||
if CodecEnabled[I] or (I = X) then
|
if CodecEnabled[I] or (I = X) or
|
||||||
|
(CodecAvailable[I] and not Assigned(Add)) then
|
||||||
begin
|
begin
|
||||||
DS := Funcs^.GetDepthCodec(DI1.Codec);
|
DS := Funcs^.GetDepthCodec(DI1.Codec);
|
||||||
Move(DS[0], DI2.Codec, SizeOf(DI2.Codec));
|
Move(DS[0], DI2.Codec, SizeOf(DI2.Codec));
|
||||||
|
@ -751,8 +753,7 @@ begin
|
||||||
L := EnsureRange(L, 1, 9);
|
L := EnsureRange(L, 1, 9);
|
||||||
M := 0;
|
M := 0;
|
||||||
I := 0;
|
I := 0;
|
||||||
Params := 'l' + L.ToString + ':' + 'w' +
|
Params := 'l' + L.ToString;
|
||||||
(GetBits(StreamInfo^.Option, 12, 3) + 8).ToString;
|
|
||||||
raw2hif_Init(HR, L);
|
raw2hif_Init(HR, L);
|
||||||
while True do
|
while True do
|
||||||
begin
|
begin
|
||||||
|
@ -793,7 +794,7 @@ begin
|
||||||
Res1 := StreamInfo^.NewSize;
|
Res1 := StreamInfo^.NewSize;
|
||||||
Res2 := P_HIFSIZE;
|
Res2 := P_HIFSIZE;
|
||||||
Buffer := Funcs^.Allocator(Instance, Res2);
|
Buffer := Funcs^.Allocator(Instance, Res2);
|
||||||
Params := 'w' + (GetBits(StreamInfo^.Option, 12, 3) + 8).ToString;
|
Params := '';
|
||||||
if preflate_decode(OldInput, StreamInfo^.OldSize, NewInput, @Res1,
|
if preflate_decode(OldInput, StreamInfo^.OldSize, NewInput, @Res1,
|
||||||
Buffer, @Res2) then
|
Buffer, @Res2) then
|
||||||
begin
|
begin
|
||||||
|
@ -868,8 +869,7 @@ begin
|
||||||
I := 0;
|
I := 0;
|
||||||
J := 0;
|
J := 0;
|
||||||
M := 0;
|
M := 0;
|
||||||
Params := 'l' + GetBits(StreamInfo.Option, 5, 7).ToString + ':' + 'w' +
|
Params := 'l' + GetBits(StreamInfo.Option, 5, 7).ToString;
|
||||||
(GetBits(StreamInfo.Option, 12, 3) + 8).ToString;
|
|
||||||
hif2raw_Init(HR, GetBits(StreamInfo.Option, 5, 7));
|
hif2raw_Init(HR, GetBits(StreamInfo.Option, 5, 7));
|
||||||
while True do
|
while True do
|
||||||
begin
|
begin
|
||||||
|
@ -904,7 +904,7 @@ begin
|
||||||
begin
|
begin
|
||||||
Res1 := StreamInfo.OldSize;
|
Res1 := StreamInfo.OldSize;
|
||||||
Buffer := Funcs^.Allocator(Instance, Res1);
|
Buffer := Funcs^.Allocator(Instance, Res1);
|
||||||
Params := 'w' + (GetBits(StreamInfo.Option, 12, 3) + 8).ToString;
|
Params := '';
|
||||||
if preflate_reencode(Input, StreamInfo.NewSize, InputExt,
|
if preflate_reencode(Input, StreamInfo.NewSize, InputExt,
|
||||||
StreamInfo.ExtSize, Buffer, @Res1) then
|
StreamInfo.ExtSize, Buffer, @Res1) then
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -320,8 +320,6 @@ begin
|
||||||
if Result or (StreamInfo^.Status >= TStreamStatus.Predicted) then
|
if Result or (StreamInfo^.Status >= TStreamStatus.Predicted) then
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
if Res1 < 0 then
|
|
||||||
exit;
|
|
||||||
if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or
|
if (Result = False) and ((StreamInfo^.Status >= TStreamStatus.Predicted) or
|
||||||
(SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then
|
(SOList[Instance][X].Count = 1)) and (DIFF_TOLERANCE > 0) then
|
||||||
begin
|
begin
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,95 @@
|
||||||
|
unit UIMain;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
LibImport,
|
||||||
|
WinAPI.Windows,
|
||||||
|
System.SysUtils, System.Classes, System.Types;
|
||||||
|
|
||||||
|
type
|
||||||
|
PUIFuncs = ^TUIFuncs;
|
||||||
|
|
||||||
|
TUIFuncs = record
|
||||||
|
IsZlibLoaded: Boolean;
|
||||||
|
IsReflateLoaded: Boolean;
|
||||||
|
IsPreflateLoaded: Boolean;
|
||||||
|
IsLZ4Loaded: Boolean;
|
||||||
|
IsLZOLoaded: Boolean;
|
||||||
|
IsZSTDLoaded: Boolean;
|
||||||
|
IsOodleLoaded: Boolean;
|
||||||
|
IsFLACLoaded: Boolean;
|
||||||
|
IsBrunsliLoaded: Boolean;
|
||||||
|
IsPackJPGLoaded: Boolean;
|
||||||
|
IsJoJpegLoaded: Boolean;
|
||||||
|
IsXDeltaLoaded: Boolean;
|
||||||
|
IsLZMALoaded: Boolean;
|
||||||
|
IsSrepAvailable: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
PLUGIN_DATABASE = 0;
|
||||||
|
PLUGIN_CONFIG = 1;
|
||||||
|
PLUGIN_LIBRARY = 2;
|
||||||
|
|
||||||
|
var
|
||||||
|
UIFuncs: TUIFuncs;
|
||||||
|
XTLUI1: procedure;
|
||||||
|
XTLUI2: function(Funcs: PUIFuncs; var Params: TArray<String>;
|
||||||
|
out LibType: Integer; out LibPath: String): Boolean;
|
||||||
|
XTLAddPlugin: procedure(S: String; I: Integer);
|
||||||
|
XTLAddCodec: procedure(S: String);
|
||||||
|
DLLLoaded: Boolean = False;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
BrunsliDLL, FLACDLL, FLZMA2DLL, JoJpegDLL, LZ4DLL, LZODLL, OodleDLL,
|
||||||
|
PackJPGDLL, PreflateDLL, ReflateDLL, XDeltaDLL, ZLibDLL, ZSTDDLL,
|
||||||
|
Utils;
|
||||||
|
|
||||||
|
var
|
||||||
|
Lib: TLibImport;
|
||||||
|
|
||||||
|
procedure Init;
|
||||||
|
begin
|
||||||
|
Lib := TLibImport.Create(ChangeFileExt(Utils.GetModuleName, 'ui.dll'));
|
||||||
|
if Lib.Loaded then
|
||||||
|
begin
|
||||||
|
@XTLUI1 := Lib.GetProcAddr('XTLUI1');
|
||||||
|
@XTLUI2 := Lib.GetProcAddr('XTLUI2');
|
||||||
|
@XTLAddPlugin := Lib.GetProcAddr('XTLAddPlugin');
|
||||||
|
@XTLAddCodec := Lib.GetProcAddr('XTLAddCodec');
|
||||||
|
DLLLoaded := Assigned(XTLUI1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Deinit;
|
||||||
|
begin
|
||||||
|
Lib.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
|
||||||
|
UIFuncs.IsZlibLoaded := ZLibDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsReflateLoaded := ReflateDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsPreflateLoaded := PreflateDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsLZ4Loaded := LZ4DLL.DLLLoaded;
|
||||||
|
UIFuncs.IsLZOLoaded := LZODLL.DLLLoaded;
|
||||||
|
UIFuncs.IsZSTDLoaded := ZSTDDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsOodleLoaded := OodleDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsFLACLoaded := FLACDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsBrunsliLoaded := BrunsliDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsPackJPGLoaded := PackJPGDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsJoJpegLoaded := JoJpegDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsXDeltaLoaded := XDeltaDLL.DLLLoaded;
|
||||||
|
UIFuncs.IsLZMALoaded := FLZMA2DLL.DLLLoaded;
|
||||||
|
UIFuncs.IsSrepAvailable := FileExists(ExtractFilePath(Utils.GetModuleName) +
|
||||||
|
'srep.exe');
|
||||||
|
Init;
|
||||||
|
|
||||||
|
finalization
|
||||||
|
|
||||||
|
Deinit;
|
||||||
|
|
||||||
|
end.
|
103
xtool.dpr
103
xtool.dpr
|
@ -62,6 +62,7 @@ uses
|
||||||
ZLibDLL in 'imports\ZLibDLL.pas',
|
ZLibDLL in 'imports\ZLibDLL.pas',
|
||||||
ZSTDDLL in 'imports\ZSTDDLL.pas',
|
ZSTDDLL in 'imports\ZSTDDLL.pas',
|
||||||
lz4 in 'sources\lz4.pas',
|
lz4 in 'sources\lz4.pas',
|
||||||
|
UIMain in 'ui\UIMain.pas',
|
||||||
PrecompMain in 'precompressor\PrecompMain.pas',
|
PrecompMain in 'precompressor\PrecompMain.pas',
|
||||||
PrecompUtils in 'precompressor\PrecompUtils.pas',
|
PrecompUtils in 'precompressor\PrecompUtils.pas',
|
||||||
PrecompCrypto in 'precompressor\PrecompCrypto.pas',
|
PrecompCrypto in 'precompressor\PrecompCrypto.pas',
|
||||||
|
@ -72,6 +73,7 @@ uses
|
||||||
PrecompMedia in 'precompressor\PrecompMedia.pas',
|
PrecompMedia in 'precompressor\PrecompMedia.pas',
|
||||||
PrecompOodle in 'precompressor\PrecompOodle.pas',
|
PrecompOodle in 'precompressor\PrecompOodle.pas',
|
||||||
PrecompINI in 'precompressor\PrecompINI.pas',
|
PrecompINI in 'precompressor\PrecompINI.pas',
|
||||||
|
PrecompINIEx in 'precompressor\PrecompINIEx.pas',
|
||||||
PrecompSearch in 'precompressor\PrecompSearch.pas',
|
PrecompSearch in 'precompressor\PrecompSearch.pas',
|
||||||
PrecompDLL in 'precompressor\PrecompDLL.pas',
|
PrecompDLL in 'precompressor\PrecompDLL.pas',
|
||||||
PrecompEXE in 'precompressor\PrecompEXE.pas',
|
PrecompEXE in 'precompressor\PrecompEXE.pas',
|
||||||
|
@ -172,15 +174,59 @@ begin
|
||||||
Result := TFileStream.Create(Output, fmCreate);
|
Result := TFileStream.Create(Output, fmCreate);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CheckInstance(const InstanceName: string): boolean;
|
||||||
|
var
|
||||||
|
Sem: THandle;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
Sem := CreateSemaphore(nil, 0, 1, PChar(InstanceName));
|
||||||
|
if ((Sem <> 0) and (GetLastError = ERROR_ALREADY_EXISTS)) then
|
||||||
|
begin
|
||||||
|
CloseHandle(Sem);
|
||||||
|
exit(True);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Exec_(Executable, CommandLine, WorkDir: string): boolean;
|
||||||
|
var
|
||||||
|
StartupInfo: TStartupInfo;
|
||||||
|
ProcessInfo: TProcessInformation;
|
||||||
|
dwExitCode: DWORD;
|
||||||
|
LWorkDir: PChar;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
FillChar(StartupInfo, sizeof(StartupInfo), #0);
|
||||||
|
StartupInfo.cb := sizeof(StartupInfo);
|
||||||
|
if WorkDir <> '' then
|
||||||
|
LWorkDir := Pointer(WorkDir)
|
||||||
|
else
|
||||||
|
LWorkDir := Pointer(GetCurrentDir);
|
||||||
|
if CreateProcess(nil, PChar('"' + Executable + '" ' + CommandLine), nil, nil,
|
||||||
|
False, 0, nil, LWorkDir, StartupInfo, ProcessInfo) then
|
||||||
|
begin
|
||||||
|
CloseHandleEx(ProcessInfo.hThread);
|
||||||
|
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
|
||||||
|
GetExitCodeProcess(ProcessInfo.hProcess, dwExitCode);
|
||||||
|
CloseHandleEx(ProcessInfo.hProcess);
|
||||||
|
Result := dwExitCode = 0;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
RaiseLastOSError;
|
||||||
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
BufferSize = 1048576;
|
BufferSize = 1048576;
|
||||||
|
|
||||||
var
|
var
|
||||||
I, J: Integer;
|
I, J: Integer;
|
||||||
S: String;
|
S: String;
|
||||||
|
LibType: Integer;
|
||||||
|
LibPath: String;
|
||||||
|
LibList: System.Types.TStringDynArray;
|
||||||
|
ParamStr_: TArray<String>;
|
||||||
ParamArg: array [0 .. 1] of TArray<String>;
|
ParamArg: array [0 .. 1] of TArray<String>;
|
||||||
StrArray: TArray<String>;
|
StrArray: TArray<String>;
|
||||||
IsParam: Boolean;
|
IsParam: boolean;
|
||||||
Input, Output: TStream;
|
Input, Output: TStream;
|
||||||
PrecompEnc: PrecompMain.TEncodeOptions;
|
PrecompEnc: PrecompMain.TEncodeOptions;
|
||||||
PrecompDec: PrecompMain.TDecodeOptions;
|
PrecompDec: PrecompMain.TDecodeOptions;
|
||||||
|
@ -207,7 +253,56 @@ end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FormatSettings := TFormatSettings.Invariant;
|
FormatSettings := TFormatSettings.Invariant;
|
||||||
|
if not CheckInstance('XToolUI_Check') then
|
||||||
ProgramInfo;
|
ProgramInfo;
|
||||||
|
if UIMain.DLLLoaded and (ParamCount = 0) then
|
||||||
|
begin
|
||||||
|
XTLUI1;
|
||||||
|
while XTLUI2(@UIFuncs, ParamStr_, LibType, LibPath) do
|
||||||
|
begin
|
||||||
|
S := '';
|
||||||
|
for I := 1 to High(ParamStr_) do
|
||||||
|
S := S + IfThen(ParamStr_[I].Contains(' '), '"' + ParamStr_[I] + '"',
|
||||||
|
ParamStr_[I]) + ' ';
|
||||||
|
PrecompMain.Parse(ParamStr_, PrecompEnc);
|
||||||
|
if LibType = 0 then
|
||||||
|
begin
|
||||||
|
WriteLine('Chunk size: ' + ConvertKB2TB(PrecompEnc.ChunkSize div 1024) +
|
||||||
|
', ' + 'Threads: ' + PrecompEnc.Threads.ToString + ', ' + 'Depth: ' +
|
||||||
|
(PrecompEnc.Depth - 1).ToString);
|
||||||
|
WriteLine('');
|
||||||
|
Exec_(ParamStr(0), S, '');
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
LibList := TDirectory.GetFiles(LibPath, '*.dll',
|
||||||
|
TSearchOption.soAllDirectories);
|
||||||
|
for J := Low(LibList) to High(LibList) do
|
||||||
|
begin
|
||||||
|
S := '';
|
||||||
|
for I := 1 to High(ParamStr_) do
|
||||||
|
begin
|
||||||
|
S := S + IfThen(ParamStr_[I].Contains(' '),
|
||||||
|
'"' + ParamStr_[I] + '"', ParamStr_[I]) + ' ';
|
||||||
|
if I = 1 then
|
||||||
|
case LibType of
|
||||||
|
1:
|
||||||
|
S := S + '"' + '-l4' + LibList[J] + '"' + ' ';
|
||||||
|
2:
|
||||||
|
S := S + '"' + '-zs' + LibList[J] + '"' + ' ';
|
||||||
|
3:
|
||||||
|
S := S + '"' + '-od' + LibList[J] + '"' + ' ';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
WriteLine('Library loaded: ' + ReplaceText(LibList[J],
|
||||||
|
IncludeTrailingBackSlash(LibPath), ''));
|
||||||
|
WriteLine('');
|
||||||
|
Exec_(ParamStr(0), S, '');
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
try
|
try
|
||||||
if ParamCount = 0 then
|
if ParamCount = 0 then
|
||||||
begin
|
begin
|
||||||
|
@ -240,6 +335,12 @@ begin
|
||||||
try
|
try
|
||||||
PrecompMain.Parse(ParamArg[0], PrecompEnc);
|
PrecompMain.Parse(ParamArg[0], PrecompEnc);
|
||||||
PrecompMain.Encode(Input, Output, PrecompEnc);
|
PrecompMain.Encode(Input, Output, PrecompEnc);
|
||||||
|
if TBufferedStream(Output).Instance is TNullStream then
|
||||||
|
begin
|
||||||
|
WriteLine('Results: ' + ConvertKB2TB(Input.Size div 1024) + ' >> ' +
|
||||||
|
ConvertKB2TB(Output.Size div 1024));
|
||||||
|
WriteLine('');
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
Input.Free;
|
Input.Free;
|
||||||
Output.Free;
|
Output.Free;
|
||||||
|
|
19
xtool.dproj
19
xtool.dproj
|
@ -48,6 +48,12 @@
|
||||||
<CfgParent>Base</CfgParent>
|
<CfgParent>Base</CfgParent>
|
||||||
<Base>true</Base>
|
<Base>true</Base>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="('$(Platform)'=='Linux64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Linux64)'!=''">
|
||||||
|
<Cfg_2_Linux64>true</Cfg_2_Linux64>
|
||||||
|
<CfgParent>Cfg_2</CfgParent>
|
||||||
|
<Cfg_2>true</Cfg_2>
|
||||||
|
<Base>true</Base>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
|
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
|
||||||
<Cfg_2_Win32>true</Cfg_2_Win32>
|
<Cfg_2_Win32>true</Cfg_2_Win32>
|
||||||
<CfgParent>Cfg_2</CfgParent>
|
<CfgParent>Cfg_2</CfgParent>
|
||||||
|
@ -119,6 +125,12 @@
|
||||||
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
||||||
<DCC_DebugInformation>0</DCC_DebugInformation>
|
<DCC_DebugInformation>0</DCC_DebugInformation>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Cfg_2_Linux64)'!=''">
|
||||||
|
<DCC_DcuOutput>.\$(Platform)\DCUs</DCC_DcuOutput>
|
||||||
|
<Debugger_Launcher>/usr/bin/gnome-terminal -- "%debuggee%"</Debugger_Launcher>
|
||||||
|
<Manifest_File>(None)</Manifest_File>
|
||||||
|
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||||
<DCC_DcuOutput>.\$(Platform)\DCUs</DCC_DcuOutput>
|
<DCC_DcuOutput>.\$(Platform)\DCUs</DCC_DcuOutput>
|
||||||
<VerInfo_Locale>7177</VerInfo_Locale>
|
<VerInfo_Locale>7177</VerInfo_Locale>
|
||||||
|
@ -134,6 +146,7 @@
|
||||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||||
<VerInfo_MajorVer>0</VerInfo_MajorVer>
|
<VerInfo_MajorVer>0</VerInfo_MajorVer>
|
||||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=0.0.0.0;InternalName=;LegalCopyright=Razor12911;LegalTrademarks=;OriginalFilename=xtool.exe;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.0.0.0;Comments=Created by Razor12911</VerInfo_Keys>
|
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=0.0.0.0;InternalName=;LegalCopyright=Razor12911;LegalTrademarks=;OriginalFilename=xtool.exe;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.0.0.0;Comments=Created by Razor12911</VerInfo_Keys>
|
||||||
|
<AppDPIAwarenessMode>none</AppDPIAwarenessMode>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<DelphiCompile Include="$(MainSource)">
|
<DelphiCompile Include="$(MainSource)">
|
||||||
|
@ -166,6 +179,7 @@
|
||||||
<DCCReference Include="imports\ZLibDLL.pas"/>
|
<DCCReference Include="imports\ZLibDLL.pas"/>
|
||||||
<DCCReference Include="imports\ZSTDDLL.pas"/>
|
<DCCReference Include="imports\ZSTDDLL.pas"/>
|
||||||
<DCCReference Include="sources\lz4.pas"/>
|
<DCCReference Include="sources\lz4.pas"/>
|
||||||
|
<DCCReference Include="ui\UIMain.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompMain.pas"/>
|
<DCCReference Include="precompressor\PrecompMain.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompUtils.pas"/>
|
<DCCReference Include="precompressor\PrecompUtils.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompCrypto.pas"/>
|
<DCCReference Include="precompressor\PrecompCrypto.pas"/>
|
||||||
|
@ -176,6 +190,7 @@
|
||||||
<DCCReference Include="precompressor\PrecompMedia.pas"/>
|
<DCCReference Include="precompressor\PrecompMedia.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompOodle.pas"/>
|
<DCCReference Include="precompressor\PrecompOodle.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompINI.pas"/>
|
<DCCReference Include="precompressor\PrecompINI.pas"/>
|
||||||
|
<DCCReference Include="precompressor\PrecompINIEx.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompSearch.pas"/>
|
<DCCReference Include="precompressor\PrecompSearch.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompDLL.pas"/>
|
<DCCReference Include="precompressor\PrecompDLL.pas"/>
|
||||||
<DCCReference Include="precompressor\PrecompEXE.pas"/>
|
<DCCReference Include="precompressor\PrecompEXE.pas"/>
|
||||||
|
@ -207,8 +222,8 @@
|
||||||
<Source Name="MainSource">xtool.dpr</Source>
|
<Source Name="MainSource">xtool.dpr</Source>
|
||||||
</Source>
|
</Source>
|
||||||
<Excluded_Packages>
|
<Excluded_Packages>
|
||||||
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k270.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
|
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k280.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||||
<Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
|
<Excluded_Packages Name="$(BDSBIN)\dclofficexp280.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||||
</Excluded_Packages>
|
</Excluded_Packages>
|
||||||
</Delphi.Personality>
|
</Delphi.Personality>
|
||||||
<Deployment Version="4">
|
<Deployment Version="4">
|
||||||
|
|
BIN
xtool.dres
BIN
xtool.dres
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
XTOOL RCDATA "cpp\\xtool\\x64\\Release\\xtool.dll"
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
library xtoolui;
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
|
||||||
|
uses
|
||||||
|
System.StartUpCopy,
|
||||||
|
FMX.Forms,
|
||||||
|
FMX.Types,
|
||||||
|
FMX.Controls,
|
||||||
|
FMX.StdCtrls,
|
||||||
|
WinAPI.Windows,
|
||||||
|
System.SysUtils,
|
||||||
|
System.Types,
|
||||||
|
System.UITypes,
|
||||||
|
System.Classes,
|
||||||
|
Unit1 in 'Unit1.pas' {Form1} ,
|
||||||
|
Unit2 in 'Unit2.pas' {Form2};
|
||||||
|
|
||||||
|
const
|
||||||
|
PLUGIN_DATABASE = 0;
|
||||||
|
PLUGIN_CONFIG = 1;
|
||||||
|
PLUGIN_LIBRARY = 2;
|
||||||
|
|
||||||
|
type
|
||||||
|
PUIFuncs = ^TUIFuncs;
|
||||||
|
|
||||||
|
TUIFuncs = record
|
||||||
|
IsZlibLoaded: Boolean;
|
||||||
|
IsReflateLoaded: Boolean;
|
||||||
|
IsPreflateLoaded: Boolean;
|
||||||
|
IsLZ4Loaded: Boolean;
|
||||||
|
IsLZOLoaded: Boolean;
|
||||||
|
IsZSTDLoaded: Boolean;
|
||||||
|
IsOodleLoaded: Boolean;
|
||||||
|
IsFLACLoaded: Boolean;
|
||||||
|
IsBrunsliLoaded: Boolean;
|
||||||
|
IsPackJPGLoaded: Boolean;
|
||||||
|
IsJoJpegLoaded: Boolean;
|
||||||
|
IsXDeltaLoaded: Boolean;
|
||||||
|
IsLZMALoaded: Boolean;
|
||||||
|
IsSrepAvailable: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
UIInitialised: Boolean = False;
|
||||||
|
|
||||||
|
procedure XTLUI1;
|
||||||
|
begin
|
||||||
|
Form1 := TForm1.Create(nil);
|
||||||
|
Form2 := TForm2.Create(Form1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function XTLUI2(Funcs: PUIFuncs; var Params: TArray<String>;
|
||||||
|
out LibType: Integer; out LibPath: String): Boolean;
|
||||||
|
var
|
||||||
|
I, J, X: Integer;
|
||||||
|
Expander: TExpander;
|
||||||
|
begin
|
||||||
|
if not UIInitialised then
|
||||||
|
begin
|
||||||
|
UIInitialised := True;
|
||||||
|
{ Form2.CheckBox3.Enabled := Funcs^.IsZlibLoaded;
|
||||||
|
Form2.CheckBox1.Enabled := Funcs^.IsReflateLoaded;
|
||||||
|
Form2.CheckBox2.Enabled := Funcs^.IsPreflateLoaded;
|
||||||
|
Form2.CheckBox4.Enabled := Funcs^.IsLZ4Loaded;
|
||||||
|
Form2.CheckBox5.Enabled := Funcs^.IsLZ4Loaded;
|
||||||
|
Form2.CheckBox6.Enabled := Funcs^.IsLZ4Loaded;
|
||||||
|
Form2.CheckBox7.Enabled := Funcs^.IsLZOLoaded;
|
||||||
|
Form2.CheckBox8.Enabled := Funcs^.IsZSTDLoaded;
|
||||||
|
Form2.CheckBox10.Enabled := Funcs^.IsOodleLoaded;
|
||||||
|
Form2.CheckBox12.Enabled := Funcs^.IsOodleLoaded;
|
||||||
|
Form2.CheckBox14.Enabled := Funcs^.IsOodleLoaded;
|
||||||
|
Form2.CheckBox16.Enabled := Funcs^.IsOodleLoaded;
|
||||||
|
Form2.CheckBox18.Enabled := Funcs^.IsOodleLoaded;
|
||||||
|
Form2.CheckBox21.Enabled := Funcs^.IsFLACLoaded;
|
||||||
|
Form2.RadioButton4.Enabled := Funcs^.IsFLACLoaded;
|
||||||
|
Form2.CheckBox26.Enabled := Funcs^.IsBrunsliLoaded or
|
||||||
|
Funcs^.IsPackJPGLoaded or Funcs^.IsJoJpegLoaded;
|
||||||
|
Form2.RadioButton1.Enabled := Funcs^.IsBrunsliLoaded;
|
||||||
|
Form2.RadioButton2.Enabled := Funcs^.IsPackJPGLoaded;
|
||||||
|
Form2.RadioButton3.Enabled := Funcs^.IsJoJpegLoaded;
|
||||||
|
Form1.GroupBox5.Enabled := Funcs^.IsLZMALoaded; }
|
||||||
|
Form1.SpinBox4.Enabled := Funcs^.IsSrepAvailable;
|
||||||
|
for I := Low(Methods) to High(Methods) do
|
||||||
|
begin
|
||||||
|
case Methods[I].FType of
|
||||||
|
PLUGIN_DATABASE:
|
||||||
|
Form2.ListBox2.Items.Add(Methods[I].FName);
|
||||||
|
PLUGIN_CONFIG:
|
||||||
|
begin
|
||||||
|
J := Length(CfgCtrls);
|
||||||
|
Insert(TConfigCtrl.Create(Form2, Form2.VertScrollBox3), CfgCtrls,
|
||||||
|
Length(CfgCtrls));
|
||||||
|
CfgCtrls[J].SetText(Methods[I].FName);
|
||||||
|
for X := Low(Methods[I].Codecs) to High(Methods[I].Codecs) do
|
||||||
|
CfgCtrls[J].AddCodec(Methods[I].Codecs[X]);
|
||||||
|
end;
|
||||||
|
PLUGIN_LIBRARY:
|
||||||
|
begin
|
||||||
|
J := Length(LibCtrls);
|
||||||
|
Insert(TLibraryCtrl.Create(Form2, Form2.VertScrollBox3), LibCtrls,
|
||||||
|
Length(LibCtrls));
|
||||||
|
LibCtrls[J].SetText(Methods[I].FName);
|
||||||
|
for X := Low(Methods[I].Codecs) to High(Methods[I].Codecs) do
|
||||||
|
LibCtrls[J].AddCodec(Methods[I].Codecs[X]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
for I := 0 to Form2.ComponentCount - 1 do
|
||||||
|
begin
|
||||||
|
if Form2.Components[I] is TExpander then
|
||||||
|
TExpander(Form2.Components[I]).IsExpanded := False;
|
||||||
|
end;
|
||||||
|
if Form2.ListBox2.Items.Count = 0 then
|
||||||
|
Form2.Expander10.Visible := False;
|
||||||
|
end;
|
||||||
|
Result := Form1.ShowModal = mrOk;
|
||||||
|
LibType := Form1.ComboBox4.ItemIndex;
|
||||||
|
LibPath := Form1.Edit5.Text;
|
||||||
|
if Result then
|
||||||
|
begin
|
||||||
|
SetLength(Params, Length(CmdStr));
|
||||||
|
for I := Low(CmdStr) to High(CmdStr) do
|
||||||
|
Params[I] := CmdStr[I];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure XTLAddPlugin(S: String; I: Integer);
|
||||||
|
var
|
||||||
|
J: Integer;
|
||||||
|
begin
|
||||||
|
J := Length(Methods);
|
||||||
|
SetLength(Methods, Succ(J));
|
||||||
|
Methods[J].FName := S;
|
||||||
|
Methods[J].FType := I;
|
||||||
|
SetLength(Methods[J].Codecs, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure XTLAddCodec(S: String);
|
||||||
|
var
|
||||||
|
J: Integer;
|
||||||
|
begin
|
||||||
|
J := Pred(Length(Methods));
|
||||||
|
Insert(S, Methods[J].Codecs, Length(Methods[J].Codecs));
|
||||||
|
end;
|
||||||
|
|
||||||
|
exports XTLUI1, XTLUI2, XTLAddPlugin, XTLAddCodec;
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
end.
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue