KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
Lazarus_7zip
★ 17
Open GitHub ↗
7-zip wrapper for Lazarus
Download README (.md)
Explore Similar Repositories
Xiegu-MiniMic
:
A Small Microphone for the Xiegu G90, X5105 and X6100 Radios
eeva
:
E²VA short for Exploitation Experience with Vulnerable App is a vulnerable app to learn userspace exploitation on Android
ND_Nitro
:
ND Framework vehicle nitro script
coseismic_practical
:
Practical exercise for the COMET InSAR course.
Compound_fault_learning
:
MATLAB codes for "Sparse Bayesian learning approach for compound bearing fault diagnosis"
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
Lazarus_7zip
?
Download (.md)
# Lazarus 7zip Create archives, extract files from archive, list files inside archives - using 7-zip DLL version 21.07. Library by Henri Gourvest updated to newer 7-zip. Version 1.3 ## About This API use the 7-zip dll (7z.dll) to read and write all 7-zip supported archive formats. According to the documentation, file formats listed below are supported, although many may only support decompression/extraction and not creation/compression. - zip - bz2 - rar - arj - z - lzh - 7z - cab - nsis - lzma - lzma86 - xz - ppmd - squashFS - cramFS - apm - mslz - flv - swf - swfc - ntfs - fat - mbr - vhd - pe - elf - macho - udf - xar - mub - hfs - dmg - compound doc - wim - iso - bkf - chm - split - rpm - deb - cpio - tar - gzip ## Detecting format ```pascal var i: Integer; Guid: TGuid; Filename: String; begin if not OpenDialog1.Execute then Exit; Filename := OpenDialog1.Filename; Guid := DetectFormat(Filename); if IsEqualGUID(Guid, CLSID_CFormat_Unsupported) then begin ShowMessage('Unsupported'); Exit; end; with CreateInArchive(Guid) do begin OpenFile(Filename); for i := 0 to NumberOfItems - 1 do if not ItemIsFolder[i] then Memo1.Lines.Add( ItemPath[i] + ' == ' + GetItemCRC(i) + ItemComment[i] +IntToStr(GetItemPackSize(i)) + ' ' + FormatDateTime('YYYY-MM-DD', GetItemModDate(i)) ); end; ``` ## Reading archive: ### Extract to path: ```pascal with CreateInArchive(CLSID_CFormatZip) do begin OpenFile('c:\test.zip'); ExtractTo('c:\test'); end; ``` ### Get file list: ```Pascal with CreateInArchive(CLSID_CFormat7z) do begin OpenFile('c:\test.7z'); for i := 0 to NumberOfItems - 1 do if not ItemIsFolder[i] then Writeln(ItemPath[i]); end; ``` ### Extract to stream ```Pascal with CreateInArchive(CLSID_CFormat7z) do begin OpenFile('c:\test.7z'); for i := 0 to NumberOfItems - 1 do if not ItemIsFolder[i] then ExtractItem(i, stream, false); end; ``` ### Extract "n" Items ```Pascal function GetStreamCallBack(sender: Pointer; index: Cardinal; var outStream: ISequentialOutStream): HRESULT; stdcall; begin case index of ... outStream := T7zStream.Create(aStream, soReference); Result := S_OK; end; procedure TMainForm.ExtractClick(Sender: TObject); var i: integer; items: array[0..2] of Cardinal; begin with CreateInArchive(CLSID_CFormat7z) do begin OpenFile('c:\test.7z'); // items must be sorted by index! items[0] := 0; items[1] := 1; items[2] := 2; ExtractItems(@items, Length(items), false, nil, GetStreamCallBack); end; end; ``` ### Open stream ```Pascal with CreateInArchive(CLSID_CFormatZip) do begin OpenStream(T7zStream.Create(TFileStream.Create('c:\test.zip', fmOpenRead), soOwned)); OpenStream(aStream, soReference); ... end; ``` ### Progress bar ```Pascal function ProgressCallback(sender: Pointer; total: boolean; value: int64): HRESULT; stdcall; begin if total then Mainform.ProgressBar.Max := value else Mainform.ProgressBar.Position := value; Result := S_OK; end; procedure TMainForm.ExtractClick(Sender: TObject); begin with CreateInArchive(CLSID_CFormatZip) do begin OpenFile('c:\test.zip'); SetProgressCallback(nil, ProgressCallback); ... end; end; ``` ### Password ```Pascal function PasswordCallback(sender: Pointer; var password: WideString): HRESULT; stdcall; begin // call a dialog box ... password := 'password'; Result := S_OK; end; procedure TMainForm.ExtractClick(Sender: TObject); begin with CreateInArchive(CLSID_CFormatZip) do begin // using callback SetPasswordCallback(nil, PasswordCallback); // or setting password directly SetPassword('password'); OpenFile('c:\test.zip'); ... end; end; ``` ### Writing archive ```Pascal procedure TMainForm.ExtractAllClick(Sender: TObject); var Arch: I7zOutArchive; begin Arch := CreateOutArchive(CLSID_CFormat7z); // add a file Arch.AddFile('c:\test.bin', 'folder\test.bin'); // add files using willcards and recursive search Arch.AddFiles('c:\test', 'folder', '*.pas;*.dfm', true); // add a stream Arch.AddStream(aStream, soReference, faArchive, CurrentFileTime, CurrentFileTime, 'folder\test.bin', false, false); // compression level SetCompressionLevel(Arch, 5); // compression method if <> LZMA SevenZipSetCompressionMethod(Arch, m7BZip2); // add a progress bar ... Arch.SetProgressCallback(...); // set a password if necessary Arch.SetPassword('password'); // Save to file Arch.SaveToFile('c:\test.zip'); // or a stream Arch.SaveToStream(aStream); end; ```