update to 0.6.9 se

This commit is contained in:
Razor12911 2022-12-31 22:45:22 +02:00
parent 722279aad5
commit 552a733296
34 changed files with 374 additions and 250 deletions

92
InitCode.pas Normal file
View File

@ -0,0 +1,92 @@
unit InitCode;
interface
uses
Utils, LibImport,
System.SysUtils;
const
PluginsParam1 = '--basedir=';
PluginsParam2 = '-bd';
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
UILib: TLibImport;
PluginsPath: String = '';
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);
UIDLLLoaded: Boolean = False;
implementation
procedure Init;
begin
UILib := TLibImport.Create(ChangeFileExt(Utils.GetModuleName, 'ui.dll'));
if UILib.Loaded then
begin
@XTLUI1 := UILib.GetProcAddr('XTLUI1');
@XTLUI2 := UILib.GetProcAddr('XTLUI2');
@XTLAddPlugin := UILib.GetProcAddr('XTLAddPlugin');
@XTLAddCodec := UILib.GetProcAddr('XTLAddCodec');
UIDLLLoaded := Assigned(XTLUI1);
end;
end;
procedure Deinit;
begin
UILib.Free;
end;
var
I: Integer;
initialization
Init;
if UIDLLLoaded and (ParamCount = 0) then
PluginsPath := IncludeTrailingBackSlash
(ExpandPath(GetIniString('UI', 'Plugins', '',
ChangeFileExt(Utils.GetModuleName, 'ui.ini'))));
for I := 1 to ParamCount do
begin
if ParamStr(I).StartsWith(PluginsParam1) then
begin
PluginsPath := ParamStr(I).Substring(PluginsParam1.Length);
break;
end;
if ParamStr(I).StartsWith(PluginsParam2) then
begin
PluginsPath := ParamStr(I).Substring(PluginsParam2.Length);
break;
end;
end;
PluginsPath := IncludeTrailingBackSlash(ExpandPath(PluginsPath));
finalization
Deinit;
end.

View File

@ -4,13 +4,14 @@ object Form1: TForm1
BorderIcons = [biSystemMenu, biMinimize] BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = Single BorderStyle = Single
Caption = 'XTool' Caption = 'XTool'
ClientHeight = 410 ClientHeight = 517
ClientWidth = 592 ClientWidth = 592
Position = ScreenCenter Position = ScreenCenter
StyleBook = StyleBook1 StyleBook = StyleBook1
FormFactor.Width = 320 FormFactor.Width = 320
FormFactor.Height = 480 FormFactor.Height = 480
FormFactor.Devices = [Desktop] FormFactor.Devices = [Desktop]
OnClose = FormClose
OnShow = FormShow OnShow = FormShow
DesignerMasterStyle = 0 DesignerMasterStyle = 0
object StyleBook1: TStyleBook object StyleBook1: TStyleBook
@ -3361,24 +3362,52 @@ object Form1: TForm1
object Layout4: TLayout object Layout4: TLayout
Align = Bottom Align = Bottom
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Position.Y = 382.000000000000000000 Position.Y = 487.000000000000000000
Size.Width = 592.000000000000000000 Size.Width = 592.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 22.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 3 TabOrder = 3
object Button1: TButton object Button1: TButton
Align = Right Align = Right
ModalResult = 1 ModalResult = 1
Margins.Left = 8.000000000000000000 Margins.Left = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 16.000000000000000000
Position.X = 504.000000000000000000 Position.X = 496.000000000000000000
Size.Width = 80.000000000000000000 Size.Width = 80.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 22.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 0 TabOrder = 1
Text = 'Start' Text = 'Start'
OnClick = Button1Click OnClick = Button1Click
end end
object Label5: TLabel
Align = Left
Margins.Left = 16.000000000000000000
Margins.Right = 8.000000000000000000
Position.X = 16.000000000000000000
Size.Width = 96.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
Text = 'Base directory'
TabOrder = 2
end
object Edit6: TEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
Align = Client
TabOrder = 0
Size.Width = 368.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
object SearchEditButton5: TSearchEditButton
CanFocus = False
Cursor = crArrow
Size.Width = 28.000000000000000000
Size.Height = 16.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
OnClick = SearchEditButton5Click
end
end
end end
object PopupMenu1: TPopupMenu object PopupMenu1: TPopupMenu
Left = 368 Left = 368
@ -3394,17 +3423,17 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Size.Width = 576.000000000000000000 Size.Width = 576.000000000000000000
Size.Height = 366.000000000000000000 Size.Height = 471.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 0 TabOrder = 0
Viewport.Width = 560.000000000000000000 Viewport.Width = 576.000000000000000000
Viewport.Height = 366.000000000000000000 Viewport.Height = 471.000000000000000000
object GroupBox1: TGroupBox object GroupBox1: TGroupBox
Align = Top Align = Top
Margins.Left = 8.000000000000000000 Margins.Left = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 54.000000000000000000 Size.Height = 54.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Input' Text = 'Input'
@ -3413,7 +3442,7 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 14 TabOrder = 14
@ -3426,7 +3455,7 @@ object Form1: TForm1
Margins.Top = 8.000000000000000000 Margins.Top = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Size.Width = 440.000000000000000000 Size.Width = 456.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 20.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
object SearchEditButton1: TSearchEditButton object SearchEditButton1: TSearchEditButton
@ -3465,7 +3494,7 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Position.Y = 108.000000000000000000 Position.Y = 108.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 90.000000000000000000 Size.Height = 90.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Options' Text = 'Options'
@ -3474,7 +3503,7 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 15 TabOrder = 15
@ -3558,7 +3587,7 @@ object Form1: TForm1
object Layout2: TLayout object Layout2: TLayout
Align = Top Align = Top
Position.Y = 52.000000000000000000 Position.Y = 52.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 14 TabOrder = 14
@ -3625,7 +3654,7 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Position.Y = 54.000000000000000000 Position.Y = 54.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 54.000000000000000000 Size.Height = 54.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Output' Text = 'Output'
@ -3634,7 +3663,7 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 14 TabOrder = 14
@ -3647,7 +3676,7 @@ object Form1: TForm1
Margins.Top = 8.000000000000000000 Margins.Top = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Size.Width = 440.000000000000000000 Size.Width = 456.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 20.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
object SearchEditButton3: TSearchEditButton object SearchEditButton3: TSearchEditButton
@ -3685,7 +3714,7 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Position.Y = 360.000000000000000000 Position.Y = 360.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 54.000000000000000000 Size.Height = 54.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Deduplication' Text = 'Deduplication'
@ -3694,7 +3723,7 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 12 TabOrder = 12
@ -3749,7 +3778,7 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Position.Y = 414.000000000000000000 Position.Y = 414.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 54.000000000000000000 Size.Height = 54.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Compression' Text = 'Compression'
@ -3758,10 +3787,10 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 13 TabOrder = 14
object Label7: TLabel object Label7: TLabel
Align = Left Align = Left
Margins.Left = 8.000000000000000000 Margins.Left = 8.000000000000000000
@ -3827,7 +3856,7 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Position.Y = 198.000000000000000000 Position.Y = 198.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 54.000000000000000000 Size.Height = 54.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Method' Text = 'Method'
@ -3836,7 +3865,7 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 14 TabOrder = 14
@ -3849,7 +3878,7 @@ object Form1: TForm1
Margins.Top = 8.000000000000000000 Margins.Top = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Size.Width = 440.000000000000000000 Size.Width = 456.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 20.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
end end
@ -3858,7 +3887,7 @@ object Form1: TForm1
Margins.Top = 8.000000000000000000 Margins.Top = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Position.X = 456.000000000000000000 Position.X = 472.000000000000000000
Position.Y = 8.000000000000000000 Position.Y = 8.000000000000000000
Size.Width = 80.000000000000000000 Size.Width = 80.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 20.000000000000000000
@ -3875,7 +3904,7 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Position.Y = 306.000000000000000000 Position.Y = 306.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 54.000000000000000000 Size.Height = 54.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Database' Text = 'Database'
@ -3884,7 +3913,7 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 14 TabOrder = 14
@ -3898,7 +3927,7 @@ object Form1: TForm1
Margins.Top = 8.000000000000000000 Margins.Top = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Size.Width = 440.000000000000000000 Size.Width = 456.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 20.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
object SearchEditButton2: TSearchEditButton object SearchEditButton2: TSearchEditButton
@ -3938,7 +3967,7 @@ object Form1: TForm1
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Position.X = 8.000000000000000000 Position.X = 8.000000000000000000
Position.Y = 252.000000000000000000 Position.Y = 252.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 54.000000000000000000 Size.Height = 54.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
Text = 'Library checker' Text = 'Library checker'
@ -3947,7 +3976,7 @@ object Form1: TForm1
Align = Top Align = Top
Margins.Top = 16.000000000000000000 Margins.Top = 16.000000000000000000
Position.Y = 16.000000000000000000 Position.Y = 16.000000000000000000
Size.Width = 544.000000000000000000 Size.Width = 560.000000000000000000
Size.Height = 36.000000000000000000 Size.Height = 36.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
TabOrder = 14 TabOrder = 14
@ -3961,7 +3990,7 @@ object Form1: TForm1
Margins.Top = 8.000000000000000000 Margins.Top = 8.000000000000000000
Margins.Right = 8.000000000000000000 Margins.Right = 8.000000000000000000
Margins.Bottom = 8.000000000000000000 Margins.Bottom = 8.000000000000000000
Size.Width = 440.000000000000000000 Size.Width = 456.000000000000000000
Size.Height = 20.000000000000000000 Size.Height = 20.000000000000000000
Size.PlatformDefault = False Size.PlatformDefault = False
object SearchEditButton4: TSearchEditButton object SearchEditButton4: TSearchEditButton

View File

@ -3,8 +3,9 @@ unit Unit1;
interface interface
uses uses
WinAPI.Windows,
System.SysUtils, System.Types, System.UITypes, System.Classes, System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants, System.Math, System.StrUtils, System.Variants, System.Math, System.StrUtils, System.IniFiles,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl,
FMX.Layouts, FMX.ListBox, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit, FMX.Layouts, FMX.ListBox, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit,
FMX.EditBox, FMX.SpinBox, FMX.Menus; FMX.EditBox, FMX.SpinBox, FMX.Menus;
@ -66,6 +67,9 @@ type
Edit5: TEdit; Edit5: TEdit;
SearchEditButton4: TSearchEditButton; SearchEditButton4: TSearchEditButton;
ComboBox4: TComboBox; ComboBox4: TComboBox;
Label5: TLabel;
Edit6: TEdit;
SearchEditButton5: TSearchEditButton;
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure SearchEditButton1Click(Sender: TObject); procedure SearchEditButton1Click(Sender: TObject);
procedure SearchEditButton3Click(Sender: TObject); procedure SearchEditButton3Click(Sender: TObject);
@ -77,6 +81,9 @@ type
procedure SearchEditButton2Click(Sender: TObject); procedure SearchEditButton2Click(Sender: TObject);
procedure ComboBox4Change(Sender: TObject); procedure ComboBox4Change(Sender: TObject);
procedure SearchEditButton4Click(Sender: TObject); procedure SearchEditButton4Click(Sender: TObject);
procedure Edit6Change(Sender: TObject);
procedure SearchEditButton5Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private private
{ Private declarations } { Private declarations }
public public
@ -87,6 +94,10 @@ var
Form1: TForm1; Form1: TForm1;
CmdStr: TArray<String>; CmdStr: TArray<String>;
function GetModuleName: string;
function GetIniString(Section, Key, Default, FileName: string): string;
procedure SetIniString(Section, Key, Value, FileName: string);
implementation implementation
{$R *.fmx} {$R *.fmx}
@ -94,6 +105,41 @@ implementation
uses uses
Unit2; Unit2;
function GetModuleName: string;
var
szFileName: array [0 .. MAX_PATH] of char;
begin
FillChar(szFileName, sizeof(szFileName), #0);
GetModuleFileName(hInstance, szFileName, MAX_PATH);
Result := szFileName;
end;
function GetIniString(Section, Key, Default, FileName: string): string;
var
Ini: TIniFile;
begin
Ini := TIniFile.Create(FileName);
with Ini do
try
Result := Ini.ReadString(Section, Key, Default);
finally
Free;
end;
end;
procedure SetIniString(Section, Key, Value, FileName: string);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create(FileName);
with Ini do
try
Ini.WriteString(Section, Key, Value);
finally
Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject); procedure TForm1.Button1Click(Sender: TObject);
begin begin
SetLength(CmdStr, 0); SetLength(CmdStr, 0);
@ -119,6 +165,7 @@ begin
if CheckBox4.IsChecked then if CheckBox4.IsChecked then
Insert('--compress=' + 't' + SpinBox2.Text + ':l' + SpinBox7.Text + ':hi' + Insert('--compress=' + 't' + SpinBox2.Text + ':l' + SpinBox7.Text + ':hi' +
IfThen(CheckBox5.IsChecked, '1', '0'), CmdStr, Length(CmdStr)); IfThen(CheckBox5.IsChecked, '1', '0'), CmdStr, Length(CmdStr));
Insert('--basedir=' + Edit6.Text, CmdStr, Length(CmdStr));
Insert(Edit1.Text, CmdStr, Length(CmdStr)); Insert(Edit1.Text, CmdStr, Length(CmdStr));
if ComboBox3.ItemIndex = 0 then if ComboBox3.ItemIndex = 0 then
Insert(Edit3.Text, CmdStr, Length(CmdStr)); Insert(Edit3.Text, CmdStr, Length(CmdStr));
@ -159,6 +206,19 @@ begin
Edit5.Text := ''; Edit5.Text := '';
end; end;
procedure TForm1.Edit6Change(Sender: TObject);
begin
ShowMessage('Restart required to reload new plugins folder.');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Edit6.Text <> GetIniString('UI', 'Plugins', '',
ChangeFileExt(GetModuleName, '.ini')) then
SetIniString('UI', 'Plugins', Edit6.Text,
ChangeFileExt(GetModuleName, '.ini'));
end;
procedure TForm1.FormShow(Sender: TObject); procedure TForm1.FormShow(Sender: TObject);
var var
I: Integer; I: Integer;
@ -218,4 +278,12 @@ begin
Edit5.Text := Dir; Edit5.Text := Dir;
end; end;
procedure TForm1.SearchEditButton5Click(Sender: TObject);
var
Dir: string;
begin
if SelectDirectory('', '', Dir) then
Edit6.Text := Dir;
end;
end. end.

View File

@ -8,6 +8,7 @@ uses
System.SysUtils, System.Classes, System.SyncObjs, System.Math, System.Types, System.SysUtils, System.Classes, System.SyncObjs, System.Math, System.Types,
System.AnsiStrings, System.StrUtils, System.IniFiles, System.IOUtils, System.AnsiStrings, System.StrUtils, System.IniFiles, System.IOUtils,
System.RTLConsts, System.TypInfo, System.ZLib, System.Net.HttpClientComponent, System.RTLConsts, System.TypInfo, System.ZLib, System.Net.HttpClientComponent,
System.Net.HttpClient,
System.Generics.Defaults, System.Generics.Collections; System.Generics.Defaults, System.Generics.Collections;
procedure ShowMessage(Msg: string; Caption: string = ''); procedure ShowMessage(Msg: string; Caption: string = '');
@ -215,7 +216,7 @@ type
TDownloadStream = class(TStream) TDownloadStream = class(TStream)
private const private const
FChunkSize = 65536; FChunkSize = 1048576;
private private
FUrl: string; FUrl: string;
FNetHTTPClient: TNetHTTPClient; FNetHTTPClient: TNetHTTPClient;
@ -466,7 +467,8 @@ 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 ExpandPath(const AFileName: string;
AFullPath: Boolean = False): 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;
@ -1448,6 +1450,8 @@ begin
end; end;
function TDownloadStream.Read(var Buffer; Count: LongInt): LongInt; function TDownloadStream.Read(var Buffer; Count: LongInt): LongInt;
var
Res: IHTTPResponse;
begin begin
if (FPosition >= 0) and (Count >= 0) then if (FPosition >= 0) and (Count >= 0) then
begin begin
@ -1459,9 +1463,9 @@ begin
Result := FSize - FPosition; Result := FSize - FPosition;
Result := Min(Result, FChunkSize); Result := Min(Result, FChunkSize);
FMemoryStream.Position := 0; FMemoryStream.Position := 0;
FNetHTTPClient.GetRange(FUrl, FPosition, FPosition + Result, Res := FNetHTTPClient.GetRange(FUrl, FPosition, FPosition + Result - 1,
FMemoryStream); FMemoryStream);
Result := FMemoryStream.Position; Result := Res.ContentLength;
Move(FMemoryStream.Memory^, Buffer, Result); Move(FMemoryStream.Memory^, Buffer, Result);
Inc(FPosition, Result); Inc(FPosition, Result);
exit; exit;
@ -3412,7 +3416,7 @@ begin
end; end;
end; end;
function ExpandPath(const AFileName: string): String; function ExpandPath(const AFileName: string; AFullPath: Boolean): String;
begin begin
if AFileName = '' then if AFileName = '' then
Result := '' Result := ''
@ -3420,6 +3424,8 @@ begin
Result := AFileName Result := AFileName
else else
Result := ExtractFilePath(GetModuleName) + AFileName; Result := ExtractFilePath(GetModuleName) + AFileName;
if AFullPath then
Result := TPath.GetFullPath(Result);
end; end;
function Exec(Executable, CommandLine, WorkDir: string): Boolean; function Exec(Executable, CommandLine, WorkDir: string): Boolean;

View File

@ -3,7 +3,8 @@ unit BrunsliDLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -44,7 +45,7 @@ var
procedure Init; procedure Init;
begin begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'brunsli.dll'); Lib := TLibImport.Create(ExpandPath(PluginsPath + 'brunsli.dll', True));
if Lib.Loaded then if Lib.Loaded then
begin begin
@brunsli_alloc_JPEGData := Lib.GetProcAddr('brunsli_alloc_JPEGData'); @brunsli_alloc_JPEGData := Lib.GetProcAddr('brunsli_alloc_JPEGData');

View File

@ -3,7 +3,8 @@ unit FLACDLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -126,8 +127,8 @@ var
procedure Init; procedure Init;
begin begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + Lib := TLibImport.Create
'libFLAC_dynamic.dll'); (ExpandPath(PluginsPath + 'libFLAC_dynamic.dll', True));
if Lib.Loaded then if Lib.Loaded then
begin begin
@FLAC__stream_encoder_new := Lib.GetProcAddr('FLAC__stream_encoder_new'); @FLAC__stream_encoder_new := Lib.GetProcAddr('FLAC__stream_encoder_new');

View File

@ -3,7 +3,8 @@ unit FLZMA2DLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes, System.Types; System.SysUtils, System.Classes, System.Types;
@ -193,9 +194,6 @@ type
implementation implementation
uses
Utils;
var var
Lib: TLibImport; Lib: TLibImport;
@ -308,7 +306,7 @@ begin
inherited Create; inherited Create;
LConfig := AConfig; LConfig := AConfig;
if LConfig = '' then if LConfig = '' then
LConfig := 't50p'; LConfig := 't25p';
FProp.Parse(LConfig); FProp.Parse(LConfig);
FInput := AInput; FInput := AInput;
LSize := 0; LSize := 0;
@ -367,7 +365,7 @@ end;
procedure Init; procedure Init;
begin begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'fast-lzma2.dll'); Lib := TLibImport.Create(ExpandPath(PluginsPath + 'fast-lzma2.dll', True));
if Lib.Loaded then if Lib.Loaded then
begin begin
@FL2_compress := Lib.GetProcAddr('FL2_compress'); @FL2_compress := Lib.GetProcAddr('FL2_compress');

View File

@ -3,7 +3,8 @@ unit JoJpegDLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -37,7 +38,7 @@ var
procedure Init; procedure Init;
begin begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'jojpeg_dll.dll'); Lib := TLibImport.Create(ExpandPath(PluginsPath + 'jojpeg_dll.dll', True));
if Lib.Loaded then if Lib.Loaded then
begin begin
@jojpeg_Init := Lib.GetProcAddr('jojpeg_Init'); @jojpeg_Init := Lib.GetProcAddr('jojpeg_Init');

View File

@ -3,6 +3,7 @@ unit LZ4DLL;
interface interface
uses uses
InitCode,
Utils, LibImport, Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Math; System.SysUtils, System.Math;
@ -198,80 +199,12 @@ begin
Result := Pos2; Result := Pos2;
end; end;
function UnravelEncode(InBuff: Pointer; InSize: Integer; OutBuff: Pointer;
OutSize: Integer): Integer;
const
blockSize = 65536;
var
ctx: PLZ4_streamHC_t;
Pos1, Pos2, Res: Integer;
X, Y: Integer;
begin
Result := 0;
ctx := LZ4_createStreamHC;
LZ4_resetStreamHC(ctx, 9);
Pos1 := 0;
Pos2 := 0;
try
while (Pos1 < InSize) do
begin
X := Min(InSize - Pos1, blockSize);
Y := OutSize - (Pos2 + Integer.Size);
Res := LZ4_compress_HC_continue(ctx, PByte(InBuff) + Pos1,
PByte(OutBuff) + Pos2 + Integer.Size, X, Y);
if Res <= 0 then
begin
LZ4_freeStreamHC(ctx);
exit(-Pos2);
end;
PInteger(PByte(OutBuff) + Pos2)^ := Res;
Inc(Pos1, X);
Inc(Pos2, Res + Integer.Size);
end;
finally
LZ4_freeStreamHC(ctx);
end;
Result := Pos2;
end;
function UnravelDecode(InBuff: Pointer; InSize: Integer; OutBuff: Pointer;
OutSize: Integer): Integer;
const
blockSize = 65536;
var
ctx: PLZ4_streamDecode_t;
Pos1, Pos2, Res: Integer;
begin
Result := 0;
ctx := LZ4_createStreamDecode;
Pos1 := 0;
Pos2 := 0;
try
while (Pos1 < InSize) and (Pos2 < OutSize) do
begin
Res := LZ4_decompress_safe_continue(ctx, PByte(InBuff) + Pos1 +
Integer.Size, PByte(OutBuff) + Pos2, PInteger(PByte(InBuff) + Pos1)^,
Min(OutSize - Pos2, blockSize));
if Res <= 0 then
begin
LZ4_freeStreamDecode(ctx);
exit(-Pos2);
end;
Inc(Pos1, PInteger(PByte(InBuff) + Pos1)^ + Integer.Size);
Inc(Pos2, Res);
end;
finally
LZ4_freeStreamDecode(ctx);
end;
Result := Pos2;
end;
var var
Lib: TLibImport; Lib: TLibImport;
procedure Init(Filename: String); procedure Init(Filename: String);
begin begin
Lib := TLibImport.Create(ExpandPath(Filename)); Lib := TLibImport.Create(ExpandPath(Filename, True));
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');
@ -320,7 +253,7 @@ var
initialization initialization
DLLFile := 'liblz4.dll'; DLLFile := PluginsPath + 'liblz4.dll';
for I := 1 to ParamCount do for I := 1 to ParamCount do
begin begin
if ParamStr(I).StartsWith(DLLParam1) then if ParamStr(I).StartsWith(DLLParam1) then

View File

@ -3,6 +3,7 @@ unit LZODLL;
interface interface
uses uses
InitCode,
Utils, LibImport, Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils; System.SysUtils;
@ -70,7 +71,7 @@ var
procedure Init(Filename: String); procedure Init(Filename: String);
begin begin
Lib := TLibImport.Create(ExpandPath(Filename)); Lib := TLibImport.Create(ExpandPath(Filename, True));
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');
@ -103,7 +104,7 @@ var
initialization initialization
DLLFile := 'lzo2.dll'; DLLFile := PluginsPath + 'lzo2.dll';
for I := 1 to ParamCount do for I := 1 to ParamCount do
begin begin
if ParamStr(I).StartsWith(DLLParam1) then if ParamStr(I).StartsWith(DLLParam1) then

View File

@ -3,6 +3,7 @@ unit OodleDLL;
interface interface
uses uses
InitCode,
Utils, LibImport, Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Types, System.IOUtils; System.SysUtils, System.Types, System.IOUtils;
@ -82,13 +83,13 @@ var
I: Integer; I: Integer;
C: Cardinal; C: Cardinal;
begin begin
Lib := TLibImport.Create(ExpandPath(Filename)); Lib := TLibImport.Create(ExpandPath(Filename, True));
if not Lib.Loaded then if not Lib.Loaded then
for I := 1 to 9 do for I := 1 to 9 do
begin begin
Lib.Free; Lib.Free;
Lib := TLibImport.Create(ExpandPath('oo2core_' + I.ToString + Lib := TLibImport.Create(ExpandPath(PluginsPath + 'oo2core_' + I.ToString
'_win64.dll')); + '_win64.dll', True));
if Lib.Loaded then if Lib.Loaded then
break; break;
end; end;
@ -96,8 +97,8 @@ begin
for I := 3 to 9 do for I := 3 to 9 do
begin begin
Lib.Free; Lib.Free;
Lib := TLibImport.Create(ExpandPath('oo2ext_' + I.ToString + Lib := TLibImport.Create(ExpandPath(PluginsPath + 'oo2ext_' + I.ToString +
'_win64.dll')); '_win64.dll', True));
if Lib.Loaded then if Lib.Loaded then
break; break;
end; end;
@ -211,7 +212,7 @@ var
initialization initialization
DLLFile := 'oo2core_9_win64.dll'; DLLFile := PluginsPath + 'oo2core_9_win64.dll';
for I := 1 to ParamCount do for I := 1 to ParamCount do
begin begin
if ParamStr(I).StartsWith(DLLParam1) then if ParamStr(I).StartsWith(DLLParam1) then

View File

@ -3,7 +3,8 @@ unit PackJPGDLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -30,7 +31,7 @@ var
procedure Init; procedure Init;
begin begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'packjpg_dll.dll'); Lib := TLibImport.Create(ExpandPath(PluginsPath + 'packjpg_dll.dll', True));
if Lib.Loaded then if Lib.Loaded then
begin begin
@pjglib_convert_stream2stream := @pjglib_convert_stream2stream :=

View File

@ -3,7 +3,8 @@ unit PreflateDLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -23,7 +24,7 @@ var
procedure Init; procedure Init;
begin begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'preflate_dll.dll'); Lib := TLibImport.Create(ExpandPath(PluginsPath + 'preflate_dll.dll', True));
if Lib.Loaded then if Lib.Loaded then
begin begin
@preflate_decode := Lib.GetProcAddr('decode'); @preflate_decode := Lib.GetProcAddr('decode');

View File

@ -3,7 +3,8 @@ unit ReflateDLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -30,8 +31,8 @@ var
procedure Init; procedure Init;
begin begin
Lib1 := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'RAW2HIF_DLL.DLL'); Lib1 := TLibImport.Create(ExpandPath(PluginsPath + 'RAW2HIF_DLL.DLL', True));
Lib2 := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'HIF2RAW_DLL.DLL'); Lib2 := TLibImport.Create(ExpandPath(PluginsPath + 'HIF2RAW_DLL.DLL', True));
if Lib1.Loaded and Lib2.Loaded then if Lib1.Loaded and Lib2.Loaded then
begin begin
@raw2hif_Alloc := Lib1.GetProcAddr('raw2hif_Alloc'); @raw2hif_Alloc := Lib1.GetProcAddr('raw2hif_Alloc');

View File

@ -3,7 +3,8 @@ unit XDeltaDLL;
interface interface
uses uses
LibImport, InitCode,
Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes; System.SysUtils, System.Classes;
@ -42,7 +43,7 @@ var
procedure Init; procedure Init;
begin begin
Lib := TLibImport.Create(ExtractFilePath(ParamStr(0)) + 'xdelta3_dll.dll'); Lib := TLibImport.Create(ExpandPath(PluginsPath + 'xdelta3_dll.dll', True));
if Lib.Loaded then if Lib.Loaded then
begin begin
DLLLoaded := True; DLLLoaded := True;

View File

@ -3,6 +3,7 @@ unit ZLibDLL;
interface interface
uses uses
InitCode,
Utils, 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 +149,11 @@ end;
procedure Init(Filename: String); procedure Init(Filename: String);
begin begin
Lib := TLibImport.Create(ExpandPath(Filename)); Lib := TLibImport.Create(ExpandPath(Filename, True));
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(ExpandPath('zlibwapi.dll')); Lib := TLibImport.Create(ExpandPath(PluginsPath + 'zlib1.dll', True));
end;
if not(Lib.Loaded and Assigned(Lib.GetProcAddr('zlibVersion'))) then
begin
Lib.Free;
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
@ -201,7 +197,7 @@ var
initialization initialization
DLLFile := 'zlibwapi.dll'; DLLFile := PluginsPath + 'zlibwapi.dll';
for I := 1 to ParamCount do for I := 1 to ParamCount do
begin begin
if ParamStr(I).StartsWith(DLLParam1) then if ParamStr(I).StartsWith(DLLParam1) then

View File

@ -3,6 +3,7 @@ unit ZSTDDLL;
interface interface
uses uses
InitCode,
Utils, LibImport, Utils, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils; System.SysUtils;
@ -147,7 +148,7 @@ var
procedure Init(Filename: String); procedure Init(Filename: String);
begin begin
Lib := TLibImport.Create(ExpandPath(Filename)); Lib := TLibImport.Create(ExpandPath(Filename, True));
if Lib.Loaded then if Lib.Loaded then
begin begin
@ZSTD_compress := Lib.GetProcAddr('ZSTD_compress'); @ZSTD_compress := Lib.GetProcAddr('ZSTD_compress');
@ -194,7 +195,7 @@ var
initialization initialization
DLLFile := 'libzstd.dll'; DLLFile := PluginsPath + 'libzstd.dll';
for I := 1 to ParamCount do for I := 1 to ParamCount do
begin begin
if ParamStr(I).StartsWith(DLLParam1) then if ParamStr(I).StartsWith(DLLParam1) then

View File

@ -7,6 +7,7 @@ unit IOExecute;
interface interface
uses uses
InitCode,
Threading, Utils, SynCommons, SynCrypto, ParseClass, ParseExpr, Threading, Utils, SynCommons, SynCrypto, ParseClass, ParseExpr,
IOUtils, IOUtils,
WinAPI.Windows, WinAPI.ShlObj, WinAPI.Windows, WinAPI.ShlObj,
@ -182,7 +183,7 @@ begin
OutFile := ReplaceText(OutFile, '[fileout]', FILE_OUT); OutFile := ReplaceText(OutFile, '[fileout]', FILE_OUT);
end; end;
if I = 0 then if I = 0 then
Exec := ExtractFilePath(Utils.GetModuleName) + S Exec := ExpandPath(PluginsPath + S, True)
else else
Param := Param + ' ' + IfThen(ContainsText(S, ' ') or (S = ''), Param := Param + ' ' + IfThen(ContainsText(S, ' ') or (S = ''),
'"' + S + '"', S); '"' + S + '"', S);

View File

@ -3,6 +3,7 @@ unit PrecompDLL;
interface interface
uses uses
InitCode,
Utils, Utils,
UIMain, UIMain,
PrecompUtils, PrecompUtils,
@ -151,14 +152,15 @@ end;
function DLLParse(Command: PChar; Option: PInteger; function DLLParse(Command: PChar; Option: PInteger;
Funcs: PPrecompFuncs): Boolean; Funcs: PPrecompFuncs): Boolean;
var var
I: Integer; I, J: Integer;
begin begin
Result := False; Result := False;
for I := Low(CodecDLL) to High(CodecDLL) do for I := Low(CodecDLL) to High(CodecDLL) do
begin begin
if IndexText(Funcs^.GetCodec(Command, 0, False), CodecDLL[I].Names) >= 0 J := IndexText(Funcs^.GetCodec(Command, 0, False), CodecDLL[I].Names);
then if J >= 0 then
begin begin
LongRec(Option^).Lo := J;
LongRec(Option^).Hi := I; LongRec(Option^).Hi := I;
Result := True; Result := True;
break; break;
@ -355,7 +357,7 @@ var
initialization initialization
DLLList := TDirectory.GetFiles(ExtractFilePath(Utils.GetModuleName), '*.dll', DLLList := TDirectory.GetFiles(ExpandPath(PluginsPath, True), '*.dll',
TSearchOption.soTopDirectoryOnly); TSearchOption.soTopDirectoryOnly);
FuncList := TStringList.Create; FuncList := TStringList.Create;
for I := Low(DLLList) to High(DLLList) do for I := Low(DLLList) to High(DLLList) do
@ -376,7 +378,7 @@ 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 if InitCode.UIDLLLoaded then
XTLAddplugin(ChangeFileExt(ExtractFileName(DLLList[I]), ''), XTLAddplugin(ChangeFileExt(ExtractFileName(DLLList[I]), ''),
PLUGIN_LIBRARY); PLUGIN_LIBRARY);
Insert(DLLStruct^, CodecDLL, Length(CodecDLL)); Insert(DLLStruct^, CodecDLL, Length(CodecDLL));
@ -387,7 +389,7 @@ 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 if InitCode.UIDLLLoaded then
XTLAddCodec(S); XTLAddCodec(S);
Inc(J); Inc(J);
end; end;
@ -398,7 +400,7 @@ 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 if InitCode.UIDLLLoaded then
XTLAddCodec(ChangeFileExt(ExtractFileName(DLLList[I]), '')); XTLAddCodec(ChangeFileExt(ExtractFileName(DLLList[I]), ''));
end; end;
end; end;

View File

@ -3,6 +3,7 @@ unit PrecompExe;
interface interface
uses uses
InitCode,
Utils, Threading, Utils, Threading,
SynCommons, SynCrypto, SynCommons, SynCrypto,
PrecompUtils, PrecompUtils,
@ -685,7 +686,8 @@ var
initialization initialization
S1 := ChangeFileExt(Utils.GetModuleName, '.ini'); S1 := ExpandPath(PluginsPath, True) +
ChangeFileExt(ExtractFileName(Utils.GetModuleName), '.ini');
if FileExists(S1) then if FileExists(S1) then
begin begin
Ini := TMemIniFile.Create(S1); Ini := TMemIniFile.Create(S1);
@ -694,7 +696,7 @@ begin
for I := 0 to SL.Count - 1 do for I := 0 to SL.Count - 1 do
begin begin
List := DecodeStr(SL[I], ','); List := DecodeStr(SL[I], ',');
if FileExists(ExtractFilePath(Utils.GetModuleName) + if FileExists(ExpandPath(PluginsPath, True) +
GetCmdStr(Ini.ReadString(SL[I], 'Decode', ''), 0)) then GetCmdStr(Ini.ReadString(SL[I], 'Decode', ''), 0)) then
for K := Low(List) to High(List) do for K := Low(List) to High(List) do
begin begin
@ -710,8 +712,7 @@ begin
else else
S1 := Ini.ReadString(SL[I], 'Decode', ''); S1 := Ini.ReadString(SL[I], 'Decode', '');
S1 := ReplaceText(S1, '<codec>', List[K]); S1 := ReplaceText(S1, '<codec>', List[K]);
ExeStruct.Exec[X] := ExtractFilePath(Utils.GetModuleName) + ExeStruct.Exec[X] := ExpandPath(PluginsPath, True) + GetCmdStr(S1, 0);
GetCmdStr(S1, 0);
ExeStruct.Param[X] := ''; ExeStruct.Param[X] := '';
ExeStruct.Mode[X] := 0; ExeStruct.Mode[X] := 0;
for J := 1 to GetCmdCount(S1) - 1 do for J := 1 to GetCmdCount(S1) - 1 do

View File

@ -3,6 +3,7 @@ unit PrecompINI;
interface interface
uses uses
InitCode,
Utils, ParseExpr, Utils, ParseExpr,
UIMain, UIMain,
PrecompUtils, PrecompUtils,
@ -379,7 +380,7 @@ var
initialization initialization
CfgList := TDirectory.GetFiles(ExtractFilePath(Utils.GetModuleName), '*.ini', CfgList := TDirectory.GetFiles(ExpandPath(PluginsPath, True), '*.ini',
TSearchOption.soTopDirectoryOnly); TSearchOption.soTopDirectoryOnly);
SL := TStringList.Create; SL := TStringList.Create;
SetLength(CodecCfg, 1); SetLength(CodecCfg, 1);
@ -391,7 +392,7 @@ 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));
if UIMain.DLLLoaded then if InitCode.UIDLLLoaded then
XTLAddplugin(S1, PLUGIN_CONFIG); XTLAddplugin(S1, PLUGIN_CONFIG);
SetLength(CodecCfg[0], Succ(Length(CodecCfg[0]))); SetLength(CodecCfg[0], Succ(Length(CodecCfg[0])));
CfgRecArray := @CodecCfg[0, Pred(Length(CodecCfg[0]))]; CfgRecArray := @CodecCfg[0, Pred(Length(CodecCfg[0]))];
@ -403,7 +404,7 @@ begin
CfgRec := @CodecCfg[0, Pred(Length(CodecCfg[0])), 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 if InitCode.UIDLLLoaded then
XTLAddCodec(CfgRec^.Name); 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,

View File

@ -3,6 +3,7 @@ unit PrecompINIEx;
interface interface
uses uses
InitCode,
Utils, ParseExpr, Utils, ParseExpr,
UIMain, UIMain,
PrecompUtils, PrecompUtils,
@ -500,7 +501,7 @@ var
initialization initialization
CfgList := TDirectory.GetFiles(ExtractFilePath(Utils.GetModuleName), '*.ini', CfgList := TDirectory.GetFiles(ExpandPath(PluginsPath, True), '*.ini',
TSearchOption.soTopDirectoryOnly); TSearchOption.soTopDirectoryOnly);
SL := TStringList.Create; SL := TStringList.Create;
SetLength(CodecCfg, 1); SetLength(CodecCfg, 1);
@ -512,7 +513,7 @@ 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));
if UIMain.DLLLoaded then if InitCode.UIDLLLoaded then
XTLAddplugin(S1, PLUGIN_CONFIG); XTLAddplugin(S1, PLUGIN_CONFIG);
SetLength(CodecCfg[0], Succ(Length(CodecCfg[0]))); SetLength(CodecCfg[0], Succ(Length(CodecCfg[0])));
CfgRecArray := @CodecCfg[0, Pred(Length(CodecCfg[0]))]; CfgRecArray := @CodecCfg[0, Pred(Length(CodecCfg[0]))];
@ -524,7 +525,7 @@ begin
CfgRec := @CodecCfg[0, Pred(Length(CodecCfg[0])), J]; CfgRec := @CodecCfg[0, Pred(Length(CodecCfg[0])), J];
CfgRec^.Parser := TExpressionParser.Create; CfgRec^.Parser := TExpressionParser.Create;
CfgRec^.Name := ReadString('StreamList' + X.ToString, 'Name', ''); CfgRec^.Name := ReadString('StreamList' + X.ToString, 'Name', '');
if UIMain.DLLLoaded then if InitCode.UIDLLLoaded then
XTLAddCodec(CfgRec^.Name); XTLAddCodec(CfgRec^.Name);
CfgRec^.Codec := ReadString('StreamList' + X.ToString, 'Codec', ''); CfgRec^.Codec := ReadString('StreamList' + X.ToString, 'Codec', '');
CfgRec^.BigEndian := ReadBool('StreamList' + X.ToString, CfgRec^.BigEndian := ReadBool('StreamList' + X.ToString,

View File

@ -31,6 +31,7 @@ const
var var
SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList; SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList;
CodecAvailable, CodecEnabled: TArray<Boolean>; CodecAvailable, CodecEnabled: TArray<Boolean>;
LMaxSize: Integer = L_MAXSIZE;
LBlockSize: Integer = L_BLOCKSIZE; LBlockSize: Integer = L_BLOCKSIZE;
LBlockDependency: Integer = L_BLOCKDEPENDENCY; LBlockDependency: Integer = L_BLOCKDEPENDENCY;
LAcceleration: Integer = L_ACCELERATION; LAcceleration: Integer = L_ACCELERATION;
@ -61,6 +62,8 @@ begin
if (CompareText(S, LZ4Codecs[LZ4_CODEC]) = 0) and LZ4DLL.DLLLoaded then if (CompareText(S, LZ4Codecs[LZ4_CODEC]) = 0) and LZ4DLL.DLLLoaded then
begin begin
CodecEnabled[LZ4_CODEC] := True; CodecEnabled[LZ4_CODEC] := True;
if Funcs^.GetParam(Command, X, 'm') <> '' then
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
if Funcs^.GetParam(Command, X, 'a') <> '' then if Funcs^.GetParam(Command, X, 'a') <> '' then
LAcceleration := StrToInt(Funcs^.GetParam(Command, X, 'a')); LAcceleration := StrToInt(Funcs^.GetParam(Command, X, 'a'));
end end
@ -72,6 +75,8 @@ begin
for I := Low(SOList) to High(SOList) do for I := Low(SOList) to High(SOList) do
SOList[I][LZ4HC_CODEC].Update SOList[I][LZ4HC_CODEC].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True); ([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
if Funcs^.GetParam(Command, X, 'm') <> '' then
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
end end
else if (CompareText(S, LZ4Codecs[LZ4F_CODEC]) = 0) and LZ4DLL.DLLLoaded else if (CompareText(S, LZ4Codecs[LZ4F_CODEC]) = 0) and LZ4DLL.DLLLoaded
then then
@ -81,6 +86,8 @@ begin
for I := Low(SOList) to High(SOList) do for I := Low(SOList) to High(SOList) do
SOList[I][LZ4F_CODEC].Update SOList[I][LZ4F_CODEC].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True); ([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
if Funcs^.GetParam(Command, X, 'm') <> '' then
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
if Funcs^.GetParam(Command, X, 'b') <> '' then if Funcs^.GetParam(Command, X, 'b') <> '' then
LBlockSize := StrToInt(Funcs^.GetParam(Command, X, 'b')) - 4; LBlockSize := StrToInt(Funcs^.GetParam(Command, X, 'b')) - 4;
if Funcs^.GetParam(Command, X, 'd') <> '' then if Funcs^.GetParam(Command, X, 'd') <> '' then
@ -182,7 +189,7 @@ begin
DI1.OldSize := SizeEx; DI1.OldSize := SizeEx;
if not CodecAvailable[X] then if not CodecAvailable[X] then
exit; exit;
Y := Max(DI1.NewSize, L_MAXSIZE); Y := Max(DI1.NewSize, LMaxSize);
Buffer := Funcs^.Allocator(Instance, Y); Buffer := Funcs^.Allocator(Instance, Y);
case X of case X of
LZ4_CODEC, LZ4HC_CODEC: LZ4_CODEC, LZ4HC_CODEC:
@ -217,7 +224,7 @@ begin
end; end;
if BoolArray(CodecEnabled, False) then if BoolArray(CodecEnabled, False) then
exit; exit;
Buffer := Funcs^.Allocator(Instance, L_MAXSIZE); Buffer := Funcs^.Allocator(Instance, LMaxSize);
Pos := 0; Pos := 0;
while Pos < Size do while Pos < Size do
begin begin
@ -225,7 +232,7 @@ begin
(CodecEnabled[LZ4HC_CODEC] and (SOList[Instance][LZ4HC_CODEC].Count = 1)) (CodecEnabled[LZ4HC_CODEC] and (SOList[Instance][LZ4HC_CODEC].Count = 1))
then then
begin begin
Y := LZ4_decompress_safe(Input + Pos, Buffer, SizeEx - Pos, L_MAXSIZE); Y := LZ4_decompress_safe(Input + Pos, Buffer, SizeEx - Pos, LMaxSize);
if Abs(Y) > 256 then if Abs(Y) > 256 then
begin begin
try try
@ -260,7 +267,7 @@ begin
if PCardinal(Input + Pos)^ = $184D2204 then if PCardinal(Input + Pos)^ = $184D2204 then
begin begin
Y := LZ4F_decompress_safe(Input + Pos, Buffer, SizeEx - Pos, Y := LZ4F_decompress_safe(Input + Pos, Buffer, SizeEx - Pos,
L_MAXSIZE, @X, @Z); LMaxSize, @X, @Z);
if (X < Y) then if (X < Y) then
begin begin
Output(Instance, Buffer, Y); Output(Instance, Buffer, Y);
@ -296,7 +303,7 @@ begin
X := GetBits(StreamInfo^.Option, 0, 5); X := GetBits(StreamInfo^.Option, 0, 5);
if StreamInfo^.OldSize <= 0 then if StreamInfo^.OldSize <= 0 then
exit; exit;
StreamInfo^.NewSize := Max(StreamInfo^.NewSize, L_MAXSIZE); StreamInfo^.NewSize := Max(StreamInfo^.NewSize, LMaxSize);
Buffer := Funcs^.Allocator(Instance, StreamInfo^.NewSize); Buffer := Funcs^.Allocator(Instance, StreamInfo^.NewSize);
case X of case X of
LZ4_CODEC, LZ4HC_CODEC: LZ4_CODEC, LZ4HC_CODEC:

View File

@ -21,8 +21,8 @@ const
LZO1C_CODEC = 2; LZO1C_CODEC = 2;
const const
L_WORKMEM = 524288;
L_MAXSIZE = 16 * 1024 * 1024; L_MAXSIZE = 16 * 1024 * 1024;
L_WORKMEM = 524288;
LZO1X_999 = 999; LZO1X_999 = 999;
LZO2A_999 = 999; LZO2A_999 = 999;
LZO1C_999 = 999; LZO1C_999 = 999;
@ -34,6 +34,7 @@ var
LZO2AVariant: Integer = LZO2A_999; LZO2AVariant: Integer = LZO2A_999;
LZO1CVariant: Integer = LZO1C_999; LZO1CVariant: Integer = LZO1C_999;
CodecAvailable, CodecEnabled: TArray<Boolean>; CodecAvailable, CodecEnabled: TArray<Boolean>;
LMaxSize: Integer = L_MAXSIZE;
type type
PLZOSI = ^TLZOSI; PLZOSI = ^TLZOSI;
@ -134,6 +135,8 @@ begin
for I := Low(SOList) to High(SOList) do for I := Low(SOList) to High(SOList) do
SOList[I][LZO1X_CODEC].Update SOList[I][LZO1X_CODEC].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True); ([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
if Funcs^.GetParam(Command, X, 'm') <> '' then
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
end end
else if (CompareText(S, LZOCodecs[LZO2A_CODEC]) = 0) and LZODLL.DLLLoaded else if (CompareText(S, LZOCodecs[LZO2A_CODEC]) = 0) and LZODLL.DLLLoaded
then then
@ -141,6 +144,8 @@ begin
CodecEnabled[LZO2A_CODEC] := True; CodecEnabled[LZO2A_CODEC] := True;
if Funcs^.GetParam(Command, X, 'v') = '999' then if Funcs^.GetParam(Command, X, 'v') = '999' then
LZO2AVariant := 999; LZO2AVariant := 999;
if Funcs^.GetParam(Command, X, 'm') <> '' then
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
end end
else if (CompareText(S, LZOCodecs[LZO1C_CODEC]) = 0) and LZODLL.DLLLoaded else if (CompareText(S, LZOCodecs[LZO1C_CODEC]) = 0) and LZODLL.DLLLoaded
then then
@ -148,6 +153,8 @@ begin
CodecEnabled[LZO1C_CODEC] := True; CodecEnabled[LZO1C_CODEC] := True;
if Funcs^.GetParam(Command, X, 'v') = '999' then if Funcs^.GetParam(Command, X, 'v') = '999' then
LZO1CVariant := 999; LZO1CVariant := 999;
if Funcs^.GetParam(Command, X, 'm') <> '' then
LMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
end; end;
Inc(X); Inc(X);
end; end;
@ -240,7 +247,7 @@ begin
exit; exit;
if not CodecAvailable[X] then if not CodecAvailable[X] then
exit; exit;
Res := Max(DI1.NewSize, L_MAXSIZE); Res := Max(DI1.NewSize, LMaxSize);
Buffer := Funcs^.Allocator(Instance, Res); Buffer := Funcs^.Allocator(Instance, Res);
case X of case X of
LZO1X_CODEC: LZO1X_CODEC:
@ -285,11 +292,11 @@ begin
end; end;
if BoolArray(CodecEnabled, False) then if BoolArray(CodecEnabled, False) then
exit; exit;
Buffer := Funcs^.Allocator(Instance, L_MAXSIZE); Buffer := Funcs^.Allocator(Instance, LMaxSize);
Pos := 0; Pos := 0;
while Pos < Size do while Pos < Size do
begin begin
if GetLZO1XSI(Input + Pos, SizeEx - Pos, Buffer, L_MAXSIZE, @LZOSI) then if GetLZO1XSI(Input + Pos, SizeEx - Pos, Buffer, LMaxSize, @LZOSI) then
begin begin
Output(Instance, Buffer, LZOSI.DSize); Output(Instance, Buffer, LZOSI.DSize);
SI.Position := Pos; SI.Position := Pos;
@ -321,7 +328,7 @@ begin
X := GetBits(StreamInfo^.Option, 0, 5); X := GetBits(StreamInfo^.Option, 0, 5);
if StreamInfo^.OldSize <= 0 then if StreamInfo^.OldSize <= 0 then
exit; exit;
Res := Max(StreamInfo^.NewSize, L_MAXSIZE); Res := Max(StreamInfo^.NewSize, LMaxSize);
Buffer := Funcs^.Allocator(Instance, Res); Buffer := Funcs^.Allocator(Instance, Res);
case X of case X of
LZO1X_CODEC: LZO1X_CODEC:

View File

@ -5,6 +5,7 @@ unit PrecompMain;
interface interface
uses uses
InitCode,
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, PrecompINIEx, PrecompSearch, PrecompOodle, PrecompMedia, PrecompINI, PrecompINIEx, PrecompSearch,
@ -197,7 +198,7 @@ begin
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(ExpandPath(PluginsPath + 'srep.exe', True)) then
begin begin
StoreDD := ArgParse.AsInteger('--dedup=', 0, StoreDD); StoreDD := ArgParse.AsInteger('--dedup=', 0, StoreDD);
StoreDD := ArgParse.AsInteger('-dd', 0, StoreDD); StoreDD := ArgParse.AsInteger('-dd', 0, StoreDD);
@ -1736,9 +1737,9 @@ begin
TBufferedStream(TempOutput).Flush; TBufferedStream(TempOutput).Flush;
if StoreDD >= 0 then if StoreDD >= 0 then
begin begin
with TProcessStream.Create(ExtractFilePath(Utils.GetModuleName) + with TProcessStream.Create(ExpandPath(PluginsPath + 'srep.exe', True),
'srep.exe', '-m' + StoreDD.ToString + 'f ' + S + ' -', GetCurrentDir, '-m' + StoreDD.ToString + 'f ' + S + ' -', GetCurrentDir, nil,
nil, Output) do Output) do
try try
if Execute then if Execute then
begin begin
@ -2113,9 +2114,8 @@ begin
begin 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(ExpandPath(PluginsPath + 'srep.exe',
'srep.exe', '-d -s -mem' + SrepMemCfg + ' - -', GetCurrentDir, True), '-d -s -mem' + SrepMemCfg + ' - -', GetCurrentDir, Input, nil);
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);

View File

@ -25,14 +25,17 @@ const
LEVIATHAN_CODEC = 5; LEVIATHAN_CODEC = 5;
const const
O_MAXSIZE = 16 * 1024 * 1024;
O_LENGTH = 32; O_LENGTH = 32;
O_TRADEOFF = 256; O_TRADEOFF = 256;
O_MAXSIZE = 16 * 1024 * 1024; O_DICTIONARY = 0;
var var
SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList; SOList: array of array [0 .. CODEC_COUNT - 1] of TSOList;
OMaxSize: Integer = O_MAXSIZE;
OLength: Integer = O_LENGTH; OLength: Integer = O_LENGTH;
OTradeOff: Integer = O_TRADEOFF; OTradeOff: Integer = O_TRADEOFF;
ODictionary: Integer = O_DICTIONARY;
CodecAvailable, CodecEnabled: TArray<Boolean>; CodecAvailable, CodecEnabled: TArray<Boolean>;
type type
@ -379,10 +382,14 @@ begin
for I := Low(SOList) to High(SOList) do for I := Low(SOList) to High(SOList) do
SOList[I][Y].Update SOList[I][Y].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True); ([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
if Funcs^.GetParam(Command, X, 'm') <> '' then
OMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
if Funcs^.GetParam(Command, X, 'n') <> '' then if Funcs^.GetParam(Command, X, 'n') <> '' then
OLength := StrToInt(Funcs^.GetParam(Command, X, 'n')); OLength := StrToInt(Funcs^.GetParam(Command, X, 'n'));
if Funcs^.GetParam(Command, X, 't') <> '' then if Funcs^.GetParam(Command, X, 't') <> '' then
OTradeOff := StrToInt(Funcs^.GetParam(Command, X, 't')); OTradeOff := StrToInt(Funcs^.GetParam(Command, X, 't'));
if Funcs^.GetParam(Command, X, 'd') <> '' then
ODictionary := StrToInt(Funcs^.GetParam(Command, X, 'd'));
end; end;
Inc(X); Inc(X);
end; end;
@ -427,6 +434,8 @@ begin
SetBits(Option^, 1, 12, 1); SetBits(Option^, 1, 12, 1);
if Funcs^.GetParam(Command, I, 't') <> '' then if Funcs^.GetParam(Command, I, 't') <> '' then
SetBits(Option^, StrToInt(Funcs^.GetParam(Command, I, 't')), 13, 11); SetBits(Option^, StrToInt(Funcs^.GetParam(Command, I, 't')), 13, 11);
if Funcs^.GetParam(Command, I, 'd') <> '' then
SetBits(Option^, StrToInt(Funcs^.GetParam(Command, I, 'd')), 24, 5);
Result := True; Result := True;
end; end;
Inc(I); Inc(I);
@ -462,7 +471,7 @@ begin
if (X in [LZNA_CODEC, LEVIATHAN_CODEC]) and (DI1.NewSize <= 0) then if (X in [LZNA_CODEC, LEVIATHAN_CODEC]) and (DI1.NewSize <= 0) then
exit; exit;
if DI1.NewSize <= 0 then if DI1.NewSize <= 0 then
Res := O_MAXSIZE Res := OMaxSize
else else
Res := DI1.NewSize; Res := DI1.NewSize;
Buffer := Funcs^.Allocator(Instance, Res); Buffer := Funcs^.Allocator(Instance, Res);
@ -619,9 +628,11 @@ begin
SizeOf(TOodleLZ_CompressOptions)); SizeOf(TOodleLZ_CompressOptions));
COptions.sendQuantumCRCs := GetBits(StreamInfo^.Option, 12, 1) = 1; COptions.sendQuantumCRCs := GetBits(StreamInfo^.Option, 12, 1) = 1;
COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo^.Option, 13, 11); COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo^.Option, 13, 11);
// COptions.dictionarySize := 262144; COptions.dictionarySize := IfThen(GetBits(StreamInfo^.Option, 24, 5) = 0, 0,
Round(Power(2, GetBits(StreamInfo^.Option, 24, 5))));
Params := 'l' + I.ToString + ':' + 'c' + GetBits(StreamInfo^.Option, 12, 1) Params := 'l' + I.ToString + ':' + 'c' + GetBits(StreamInfo^.Option, 12, 1)
.ToString + ':' + 't' + GetBits(StreamInfo^.Option, 13, 11).ToString; .ToString + ':' + 't' + GetBits(StreamInfo^.Option, 13, 11).ToString + ':'
+ 'd' + GetBits(StreamInfo^.Option, 24, 5).ToString;
if not Result then if not Result then
Res1 := OodleLZ_Compress(Y, NewInput, StreamInfo^.NewSize, Buffer, I, Res1 := OodleLZ_Compress(Y, NewInput, StreamInfo^.NewSize, Buffer, I,
@COptions); @COptions);
@ -677,9 +688,12 @@ begin
COptions, SizeOf(TOodleLZ_CompressOptions)); COptions, SizeOf(TOodleLZ_CompressOptions));
COptions.sendQuantumCRCs := GetBits(StreamInfo.Option, 12, 1) = 1; COptions.sendQuantumCRCs := GetBits(StreamInfo.Option, 12, 1) = 1;
COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo.Option, 13, 11); COptions.spaceSpeedTradeoffBytes := GetBits(StreamInfo.Option, 13, 11);
COptions.dictionarySize := IfThen(GetBits(StreamInfo.Option, 24, 5) = 0, 0,
Round(Power(2, GetBits(StreamInfo.Option, 24, 5))));
Params := 'l' + GetBits(StreamInfo.Option, 5, 7).ToString + ':' + 'c' + Params := 'l' + GetBits(StreamInfo.Option, 5, 7).ToString + ':' + 'c' +
GetBits(StreamInfo.Option, 12, 1).ToString + ':' + 't' + GetBits(StreamInfo.Option, 12, 1).ToString + ':' + 't' +
GetBits(StreamInfo.Option, 13, 11).ToString; GetBits(StreamInfo.Option, 13, 11).ToString + ':' + 'd' +
GetBits(StreamInfo.Option, 24, 5).ToString;
Res1 := OodleLZ_Compress(Y, Input, StreamInfo.NewSize, Buffer, Res1 := OodleLZ_Compress(Y, Input, StreamInfo.NewSize, Buffer,
GetBits(StreamInfo.Option, 5, 7), @COptions); GetBits(StreamInfo.Option, 5, 7), @COptions);
Funcs^.LogRestore(OodleCodecs[GetBits(StreamInfo.Option, 0, 5)], Funcs^.LogRestore(OodleCodecs[GetBits(StreamInfo.Option, 0, 5)],

View File

@ -3,6 +3,7 @@ unit PrecompSearch;
interface interface
uses uses
InitCode,
Utils, SynCommons, SynCrypto, Utils, SynCommons, SynCrypto,
UIMain, UIMain,
PrecompUtils, PrecompUtils,
@ -265,7 +266,7 @@ var
initialization initialization
SearchList := TDirectory.GetFiles(ExtractFilePath(Utils.GetModuleName), '*.xtl', SearchList := TDirectory.GetFiles(ExpandPath(PluginsPath, True), '*.xtl',
TSearchOption.soTopDirectoryOnly); TSearchOption.soTopDirectoryOnly);
for I := Low(SearchList) to High(SearchList) do for I := Low(SearchList) to High(SearchList) do
begin begin
@ -282,7 +283,7 @@ 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 if InitCode.UIDLLLoaded then
XTLAddplugin(S, PLUGIN_DATABASE); XTLAddplugin(S, PLUGIN_DATABASE);
end; end;
while FStream.Position < FStream.Size do while FStream.Position < FStream.Size do

View File

@ -27,6 +27,7 @@ var
// cdict, ddict: Pointer; // cdict, ddict: Pointer;
DStream: TMemoryStream; DStream: TMemoryStream;
CodecAvailable, CodecEnabled: TArray<Boolean>; CodecAvailable, CodecEnabled: TArray<Boolean>;
ZMaxSize: Integer = Z_MAXSIZE;
function ZSTDInit(Command: PChar; Count: Integer; Funcs: PPrecompFuncs) function ZSTDInit(Command: PChar; Count: Integer; Funcs: PPrecompFuncs)
: Boolean; : Boolean;
@ -59,6 +60,8 @@ begin
for I := Low(SOList) to High(SOList) do for I := Low(SOList) to High(SOList) do
SOList[I][ZSTD_CODEC].Update SOList[I][ZSTD_CODEC].Update
([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True); ([StrToInt(Funcs^.GetParam(Command, X, 'l'))], True);
if Funcs^.GetParam(Command, X, 'm') <> '' then
ZMaxSize := ConvertToBytes(Funcs^.GetParam(Command, X, 'm'));
end; end;
Inc(X); Inc(X);
end; end;
@ -143,7 +146,7 @@ begin
exit; exit;
Y := ZSTD_findDecompressedSize(Input, SizeEx); Y := ZSTD_findDecompressedSize(Input, SizeEx);
if Y <= 0 then if Y <= 0 then
Y := Z_MAXSIZE; Y := ZMaxSize;
Buffer := Funcs^.Allocator(Instance, Y); Buffer := Funcs^.Allocator(Instance, Y);
case X of case X of
ZSTD_CODEC: ZSTD_CODEC:
@ -183,7 +186,7 @@ begin
begin begin
Z := ZSTD_findDecompressedSize(Input + Pos, X); Z := ZSTD_findDecompressedSize(Input + Pos, X);
if Z <= 0 then if Z <= 0 then
Z := Z_MAXSIZE; Z := ZMaxSize;
Buffer := Funcs^.Allocator(Instance, Z); Buffer := Funcs^.Allocator(Instance, Z);
Y := ZSTD_decompressDCtx(dctx[Instance], Buffer, Z, Input + Pos, X); Y := ZSTD_decompressDCtx(dctx[Instance], Buffer, Z, Input + Pos, X);
// Y := ZSTD_decompress_usingDDict(dctx[Instance], Buffer, Z, Input + Pos, X, ddict); // Y := ZSTD_decompress_usingDDict(dctx[Instance], Buffer, Z, Input + Pos, X, ddict);
@ -224,7 +227,7 @@ begin
if StreamInfo^.NewSize <= 0 then if StreamInfo^.NewSize <= 0 then
StreamInfo^.NewSize := ZSTD_findDecompressedSize(Input, Size); StreamInfo^.NewSize := ZSTD_findDecompressedSize(Input, Size);
if StreamInfo^.NewSize <= 0 then if StreamInfo^.NewSize <= 0 then
StreamInfo^.NewSize := Z_MAXSIZE; StreamInfo^.NewSize := ZMaxSize;
Buffer := Funcs^.Allocator(Instance, StreamInfo^.NewSize); Buffer := Funcs^.Allocator(Instance, StreamInfo^.NewSize);
case X of case X of
ZSTD_CODEC: ZSTD_CODEC:

View File

@ -3,30 +3,11 @@ unit UIMain;
interface interface
uses uses
InitCode,
LibImport, LibImport,
WinAPI.Windows, WinAPI.Windows,
System.SysUtils, System.Classes, System.Types; 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 const
PLUGIN_DATABASE = 0; PLUGIN_DATABASE = 0;
PLUGIN_CONFIG = 1; PLUGIN_CONFIG = 1;
@ -34,12 +15,6 @@ const
var var
UIFuncs: TUIFuncs; 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 implementation
@ -48,27 +23,6 @@ uses
PackJPGDLL, PreflateDLL, ReflateDLL, XDeltaDLL, ZLibDLL, ZSTDDLL, PackJPGDLL, PreflateDLL, ReflateDLL, XDeltaDLL, ZLibDLL, ZSTDDLL,
Utils; 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 initialization
UIFuncs.IsZlibLoaded := ZLibDLL.DLLLoaded; UIFuncs.IsZlibLoaded := ZLibDLL.DLLLoaded;
@ -84,12 +38,7 @@ UIFuncs.IsPackJPGLoaded := PackJPGDLL.DLLLoaded;
UIFuncs.IsJoJpegLoaded := JoJpegDLL.DLLLoaded; UIFuncs.IsJoJpegLoaded := JoJpegDLL.DLLLoaded;
UIFuncs.IsXDeltaLoaded := XDeltaDLL.DLLLoaded; UIFuncs.IsXDeltaLoaded := XDeltaDLL.DLLLoaded;
UIFuncs.IsLZMALoaded := FLZMA2DLL.DLLLoaded; UIFuncs.IsLZMALoaded := FLZMA2DLL.DLLLoaded;
UIFuncs.IsSrepAvailable := FileExists(ExtractFilePath(Utils.GetModuleName) + UIFuncs.IsSrepAvailable :=
'srep.exe'); FileExists(ExpandPath(PluginsPath + 'srep.exe', True));
Init;
finalization
Deinit;
end. end.

View File

@ -48,6 +48,7 @@ uses
oObjects in 'contrib\ParseExpression\oObjects.pas', oObjects in 'contrib\ParseExpression\oObjects.pas',
ParseClass in 'contrib\ParseExpression\ParseClass.pas', ParseClass in 'contrib\ParseExpression\ParseClass.pas',
ParseExpr in 'contrib\ParseExpression\ParseExpr.pas', ParseExpr in 'contrib\ParseExpression\ParseExpr.pas',
InitCode in 'InitCode.pas',
BrunsliDLL in 'imports\BrunsliDLL.pas', BrunsliDLL in 'imports\BrunsliDLL.pas',
FLACDLL in 'imports\FLACDLL.pas', FLACDLL in 'imports\FLACDLL.pas',
FLZMA2DLL in 'imports\FLZMA2DLL.pas', FLZMA2DLL in 'imports\FLZMA2DLL.pas',
@ -255,7 +256,7 @@ begin
FormatSettings := TFormatSettings.Invariant; FormatSettings := TFormatSettings.Invariant;
if not CheckInstance('XToolUI_Check') then if not CheckInstance('XToolUI_Check') then
ProgramInfo; ProgramInfo;
if UIMain.DLLLoaded and (ParamCount = 0) then if InitCode.UIDLLLoaded and (ParamCount = 0) then
begin begin
XTLUI1; XTLUI1;
while XTLUI2(@UIFuncs, ParamStr_, LibType, LibPath) do while XTLUI2(@UIFuncs, ParamStr_, LibType, LibPath) do

View File

@ -165,6 +165,7 @@
<DCCReference Include="contrib\ParseExpression\oObjects.pas"/> <DCCReference Include="contrib\ParseExpression\oObjects.pas"/>
<DCCReference Include="contrib\ParseExpression\ParseClass.pas"/> <DCCReference Include="contrib\ParseExpression\ParseClass.pas"/>
<DCCReference Include="contrib\ParseExpression\ParseExpr.pas"/> <DCCReference Include="contrib\ParseExpression\ParseExpr.pas"/>
<DCCReference Include="InitCode.pas"/>
<DCCReference Include="imports\BrunsliDLL.pas"/> <DCCReference Include="imports\BrunsliDLL.pas"/>
<DCCReference Include="imports\FLACDLL.pas"/> <DCCReference Include="imports\FLACDLL.pas"/>
<DCCReference Include="imports\FLZMA2DLL.pas"/> <DCCReference Include="imports\FLZMA2DLL.pas"/>

BIN
xtool.res

Binary file not shown.

View File

@ -59,6 +59,9 @@ begin
if not UIInitialised then if not UIInitialised then
begin begin
UIInitialised := True; UIInitialised := True;
Form1.Edit6.Text := GetIniString('UI', 'Plugins', '',
ChangeFileExt(GetModuleName, '.ini'));
Form1.Edit6.OnChange := Form1.Edit6Change;
{ Form2.CheckBox3.Enabled := Funcs^.IsZlibLoaded; { Form2.CheckBox3.Enabled := Funcs^.IsZlibLoaded;
Form2.CheckBox1.Enabled := Funcs^.IsReflateLoaded; Form2.CheckBox1.Enabled := Funcs^.IsReflateLoaded;
Form2.CheckBox2.Enabled := Funcs^.IsPreflateLoaded; Form2.CheckBox2.Enabled := Funcs^.IsPreflateLoaded;

Binary file not shown.