unit unit3;
{$mode objfpc}{$H+}
interface
uses
Windows, Messages, SysUtils, Classes, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, Menus, Interfaces, MD5, Variants, ZLib, ZStream, Tar;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
OpenDialog1: TOpenDialog;
SelectDirectoryDialog1: TSelectDirectoryDialog;
SpeedButton1: TSpeedButton;
procedure Button1Click(Sender: TObject);
procedure Label2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Label2Click(Sender: TObject);
var
CVDFile: TMemoryStream;
GZFile: TMemoryStream;
TarFile: TMemoryStream;
Tar: TTarArchive;
TDir: TTarDirRec;
DesFile: String;
GZStream: TDecompressionStream;
begin
CVDFile := TMemoryStream.Create;
CVDFile.LoadFromFile(Edit1.Text);
CVDFile.Position := 512;
GZFile := TMemoryStream.Create;
GZFile.CopyFrom(CVDFile, CVDFile.Size - 512);
GZFile.Position := 0;
TarFile := TMemoryStream.Create;
GZStream := TDecompressionStream.Create(GZFile);
try
TarFile.CopyFrom(GZStream, GZStream.Size);
finally
GZStream.Free;
end;
TarFile.SaveToFile(ExtractFilePath(ParamStr(0)) +
ExtractFileName(Edit1.Text) + '.tar');
Tar := TTarArchive.Create(ExtractFilePath(ParamStr(0)) +
ExtractFileName(Edit1.Text) + '.tar');
try
Tar.Reset;
while Tar.FindNext(TDir) do
begin
DesFile := ExtractFilePath(ParamStr(0)) + TDir.Name;
Tar.ReadFile(DesFile);
end;
except
on Exception do
end;
Tar.Free;
CVDFile.Free;
GZFile.Free;
TarFile.Free;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
Edit1.Text := OpenDialog1.FileName;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
CVDFile: TMemoryStream;
GZFile: TMemoryStream;
TarFile: TMemoryStream;
Tar: TTarArchive;
begin
try
// Your code logic goes here
except
on E: Exception do
begin
ShowMessage('An exception occurred: ' + E.Message);
end;
end;
end;
end. I got this errors: Hint: (11030) Start of reading config file C:\lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.2.2 [2023/03/04] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling project2.lpr
C:\Users\semae\OneDrive\Belgeler\project2.lpr(13,17) Hint: (5023) Unit "ZLibExGZ" not used in project2
C:\Users\semae\OneDrive\Belgeler\project2.lpr(13,27) Hint: (5023) Unit "ZLibEx" not used in project2
(9022) Compiling resource C:\Users\semae\OneDrive\Belgeler\lib\x86_64-win64\project2.obj
(9015) Linking C:\Users\semae\OneDrive\Belgeler\project2.exe
C:\Users\semae\OneDrive\Belgeler\project2.lpr(29,1) Error: Undefined symbol: memcpy
C:\Users\semae\OneDrive\Belgeler\project2.lpr(29,1) Error: Undefined symbol: memset
C:\Users\semae\OneDrive\Belgeler\project2.lpr(29,1) Error: Undefined symbol: zcalloc
C:\Users\semae\OneDrive\Belgeler\project2.lpr(29,1) Error: Undefined symbol: zcfree
C:\Users\semae\OneDrive\Belgeler\project2.lpr(29,1) Error: Undefined symbol: z_errmsg
C:\Users\semae\OneDrive\Belgeler\project2.lpr(29,1) Error: Undefined symbol: __ImageBase
C:\Users\semae\OneDrive\Belgeler\project2.lpr(29,1) Fatal: (10026) There were 6 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: C:\lazarus\fpc\3.2.2\bin\x86_64-win64\ppcx64.exe returned an error exitcode