Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
045f728
added lzma static library
lejcik Dec 8, 2023
be00ee5
added zstd static library
lejcik Dec 8, 2023
8857ee1
added support for zstd and xz archives
lejcik Dec 8, 2023
4053035
corrected wrong order of internal files in a .deb archive
lejcik Dec 8, 2023
e52ebce
updated plugin configuration registration
lejcik Dec 8, 2023
859ce65
added porting info for the imported libs
lejcik Dec 8, 2023
cf64eef
tar plugin: updated to version 3.4.0
lejcik Dec 8, 2023
f99ecc2
one more forgotten note
lejcik Dec 8, 2023
60d56e3
reformated with clang-format
lejcik Dec 8, 2023
06e77fb
Merge branch 'main' into plugin-tar-added-zstd-and-lzma-support
lejcik Dec 22, 2023
5a35541
Merge branch 'main' into plugin-tar-added-zstd-and-lzma-support
lejcik Dec 30, 2023
114e951
used vcpkg to handle external dependencies
lejcik Dec 30, 2023
5890216
reverted a few more leftovers
lejcik Dec 30, 2023
a2374fe
updated about-box
lejcik Dec 30, 2023
5343120
reverted salamand.sln
lejcik Jan 2, 2024
c802c64
fixed a warning
lejcik Jan 2, 2024
f0725c7
code improvements from static analysis
lejcik Jan 2, 2024
69410b3
reverted a typo
lejcik Jan 2, 2024
023d3c2
tar project file update
lejcik Jan 2, 2024
b554a2c
got rid of unused function
lejcik Sep 14, 2025
60c2bca
added support for extracting bzip3 archives
lejcik Sep 14, 2025
17c0ae7
tar plugin: updated to version 3.5.0
lejcik Sep 14, 2025
bf09ef7
Merge branch 'main' into plugin-tar-added-zstd-and-lzma-support
lejcik Sep 15, 2025
2f684e6
tar translations
lejcik Feb 22, 2026
0074b15
Merge branch 'main' into plugin-tar-added-zstd-and-lzma-support
lejcik Feb 22, 2026
02284d4
updated vcpkg release hash to version 2026.01.16
lejcik Feb 22, 2026
c335bc6
updated comments translations
lejcik Feb 22, 2026
6b47e0a
updated about message
lejcik Feb 22, 2026
e95e34b
Merge branch 'main' into plugin-tar-added-zstd-and-lzma-support
lejcik May 15, 2026
4cf3d2f
Merge branch 'main' into plugin-tar-added-zstd-and-lzma-support
lejcik Aug 1, 2026
2f82c21
minor code improvement
lejcik Aug 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions src/plugins/tar/beta.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ version 3.30: (2009.02.28) J.Patera
-CDecompressFile::Rewind() did not update StreamPos -> CPIO (e_OldASCII)
archives could not open
-GZIP: files longer than 4 GB before compression complained about premature EOF

version 3.40: (2021.11.12) Vilo
+LZMA: Added support for .XZ archives
+ZSTD: Added support for .ZST archives
2 changes: 1 addition & 1 deletion src/plugins/tar/bzip/bunzip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ CBZip::DecompressBlock(unsigned short needed)
return FALSE;
}
BZStream->next_in = (char *)DataStart;
BZStream->avail_in = (unsigned int)(DataEnd - DataStart);
BZStream->avail_in = GetUnreadInputBufferSize();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was some issue with computing available buffer size, but now I don't remember the details...

BZStream->next_out = (char *)ExtrEnd;
BZStream->avail_out = BUFSIZE - (unsigned int)(ExtrEnd - Window);
ret = BZ2_bzDecompress(BZStream);
Expand Down
40 changes: 31 additions & 9 deletions src/plugins/tar/deb/deb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ CDEBArchive::CDEBArchive(const char* fileName, CSalamanderForOperationsAbstract*
pos += sizeof(ARBlock);

// Open the fist subarchive
controlArchive = new CArchive(fileName, salamander, pos, CQuadWord(SubArchiveSize, 0));
if (!controlArchive->IsOk())
CArchive *archive = new CArchive(fileName, salamander, pos, CQuadWord(SubArchiveSize, 0));

@lejcik lejcik Dec 8, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the expected sub-archives can be in reverse order, data first and control last, this is a fix for such case

if (!archive->IsOk())
{
delete controlArchive;
controlArchive = NULL;
delete archive;
archive = NULL;
return;
}
// We are happy if at least one subarchive was recognized
bOK = TRUE;
if (AssignArchive(ARBlock.FileName, archive))
bOK = TRUE;

// Skip the subarchive and read the 3rd and last subarchive
if (SubArchiveSize & 1)
Expand All @@ -127,12 +128,15 @@ CDEBArchive::CDEBArchive(const char* fileName, CSalamanderForOperationsAbstract*
return;
}
sscanf(ARBlock.FileSize, "%u", &SubArchiveSize);
dataArchive = new CArchive(fileName, salamander, pos + sizeof(ARBlock), CQuadWord(0, 0));
if (!dataArchive->IsOk())
pos += sizeof(ARBlock);
archive = new CArchive(fileName, salamander, pos, CQuadWord(SubArchiveSize, 0));
if (!archive->IsOk())
{
delete dataArchive;
dataArchive = NULL;
delete archive;
archive = NULL;
}
if (AssignArchive(ARBlock.FileName, archive))
bOK = TRUE;
CloseHandle(file);
}

Expand Down Expand Up @@ -315,3 +319,21 @@ BOOL CDEBArchive::UnpackWholeArchive(const char* mask, const char* targetPath)
}
return ret;
}

BOOL CDEBArchive::AssignArchive(const char* archName, CArchive* archive)
{
if (!controlArchive && !strncmp(archName, DEB_STREAM_NAME_CONTROL".", sizeof(DEB_STREAM_NAME_CONTROL".") - 1))
{
controlArchive = archive;
return TRUE;
}
else if (!dataArchive && !strncmp(archName, DEB_STREAM_NAME_DATA".", sizeof(DEB_STREAM_NAME_DATA".") - 1))
{
dataArchive = archive;
return TRUE;
}

// archiv se uz nebude pouzivat
delete archive;
return FALSE;
}
3 changes: 3 additions & 0 deletions src/plugins/tar/deb/deb.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ class CDEBArchive : public CArchiveAbstract
BOOL UnpackWholeArchive(const char* mask, const char* targetPath);

BOOL IsOk() { return bOK; };

private:
BOOL AssignArchive(const char *archName, CArchive *archive);
};
35 changes: 27 additions & 8 deletions src/plugins/tar/fileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "compress/compress.h"
#include "rpm/rpm.h"
#include "lzh/lzh.h"
#include "lzma/unlzma.h"
#include "zstd/unzstd.h"

#include "tar.rh"
#include "tar.rh2"
Expand Down Expand Up @@ -97,14 +99,26 @@ CDecompressFile::CreateInstance(LPCTSTR fileName, DWORD inputOffset, CQuadWord i
archive = new CBZip(fileName, file, buffer, inputOffset, read, inputSize);
if (archive != NULL && !archive->IsOk() && archive->GetErrorCode() == 0)
{
// neni to compress, zkusime lzh
// neni to bzip, zkusime lzh
delete archive;
archive = new CLZH(fileName, file, buffer, read);
if (archive != NULL && !archive->IsOk() && archive->GetErrorCode() == 0)
{
// neni to kompresene, berem zakladni tridu
// neni to lzh, zkusime lzma
delete archive;
archive = new CDecompressFile(fileName, file, buffer, inputOffset, read, inputSize);
archive = new CLZMa(fileName, file, buffer, inputOffset, read, inputSize);
if (archive != NULL && !archive->IsOk() && archive->GetErrorCode() == 0)
{
// neni to lzma, zkusime zstd
delete archive;
archive = new CZStd(fileName, file, buffer, inputOffset, read, inputSize);
if (archive != NULL && !archive->IsOk() && archive->GetErrorCode() == 0)
{
// neni to kompresene, berem zakladni tridu
delete archive;
archive = new CDecompressFile(fileName, file, buffer, inputOffset, read, inputSize);
}
}
}
}
}
Expand All @@ -129,8 +143,9 @@ CDecompressFile::CreateInstance(LPCTSTR fileName, DWORD inputOffset, CQuadWord i
}

// class constructor
CDecompressFile::CDecompressFile(const char* filename, HANDLE file, unsigned char* buffer, unsigned long start, unsigned long read, CQuadWord inputSize) : FileName(filename), File(file), Buffer(buffer), DataStart(buffer), DataEnd(buffer + read),
OldName(NULL), Ok(TRUE), StreamPos(start, 0), ErrorCode(0), LastError(0), FreeBufAndFile(TRUE)
CDecompressFile::CDecompressFile(const char* filename, HANDLE file, unsigned char* buffer, unsigned long start, unsigned long read, CQuadWord inputSize) :
FileName(filename), File(file), Buffer(buffer), DataStart(buffer), DataEnd(buffer + read),
OldName(NULL), Ok(TRUE), InputPos(0, 0), StreamPos(start, 0), ErrorCode(0), LastError(0), FreeBufAndFile(TRUE)
{
CALL_STACK_MESSAGE3("CDecompressFile::CDecompressFile(%s, , %u)", filename, read);

Expand Down Expand Up @@ -204,9 +219,9 @@ CDecompressFile::FReadBlock(unsigned int number)
{
DWORD read = (DWORD)(Buffer + BUFSIZE - DataEnd);

if (StreamPos.Value + read > InputSize.Value)
if (InputPos.Value + read > InputSize.Value)
{
read = (DWORD)(InputSize.Value - StreamPos.Value);
read = (DWORD)(InputSize.Value - InputPos.Value);
}

if (!ReadFile(File, DataEnd, read, &read, NULL))
Expand All @@ -230,6 +245,7 @@ CDecompressFile::FReadBlock(unsigned int number)
// upravime ukazatele
DataStart += number;
StreamPos += CQuadWord(number, 0);
InputPos = min(InputPos + CQuadWord(number, 0), InputSize);
// a vratime vysledek
return ret;
}
Expand Down Expand Up @@ -274,6 +290,7 @@ CDecompressFile::FReadByte()
}
// upravime ukazatele
++StreamPos;
InputPos = min(++InputPos, InputSize);
return *(DataStart++);
}

Expand Down Expand Up @@ -313,6 +330,7 @@ void CDecompressFile::Rewind(unsigned short size)
{
DataStart -= size;
StreamPos.Value -= size;
InputPos.Value -= size;
}
else
{
Expand Down Expand Up @@ -347,7 +365,8 @@ void CDecompressFile::GetFileInfo(FILETIME& lastWrite, CQuadWord& fileSize, DWOR
// CZippedFile
//

CZippedFile::CZippedFile(const char* filename, HANDLE file, unsigned char* buffer, unsigned long start, unsigned long read, CQuadWord inputSize) : CDecompressFile(filename, file, buffer, start, read, inputSize), Window(NULL), ExtrStart(NULL), ExtrEnd(NULL)
CZippedFile::CZippedFile(const char* filename, HANDLE file, unsigned char* buffer, unsigned long start, unsigned long read, CQuadWord inputSize) :
CDecompressFile(filename, file, buffer, start, read, inputSize), Window(NULL), ExtrStart(NULL), ExtrEnd(NULL)
{
// pokud neprosel konstruktor parenta, balime to rovnou
if (!Ok)
Expand Down
19 changes: 12 additions & 7 deletions src/plugins/tar/fileio.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@ class CDecompressFile
virtual BOOL BuggySize() { return FALSE; }

// vraci, v jakem jsme stavu
BOOL IsOk() { return Ok; }
BOOL IsOk() const { return Ok; }
// pokud nastala chyba, vraci jeji kod
const unsigned int GetErrorCode() { return ErrorCode; }
unsigned int GetErrorCode() const { return ErrorCode; }
// pokud nastala systemova chyba (I/O etc.) vraci blizsi urceni (::GetLastError())
const DWORD GetLastErr() { return LastError; }
DWORD GetLastErr() const { return LastError; }
// vraci velikost bufferu s neprectenymi datami
size_t GetUnreadInputBufferSize() const { return min(size_t(DataEnd - DataStart), (InputSize - InputPos).LoDWord); }
// vraci velikost archivu na disku
CQuadWord GetStreamSize() { return InputSize; }
CQuadWord GetStreamSize() const { return InputSize; }
// vraci soucasnou pozici v aktualnim souboru v archivu na disku
CQuadWord GetInputPos() const { return InputPos; }
// vraci soucasnou pozici v archivu na disku
CQuadWord GetStreamPos() { return StreamPos; }
CQuadWord GetStreamPos() const { return StreamPos; }
// vrati puvodni nazev souboru, ktery byl v archivu (nazev taru v gzipu apod.)
const char* GetOldName();
// vrati nazev souboru, se kterym pracuje (jmeno archivu)
const char* GetArchiveName() { return FileName; }
const char* GetArchiveName() const { return FileName; }

// vrati cast nebo cely posledni precteny blok k dalsimu pouziti
virtual void Rewind(unsigned short size);
Expand All @@ -53,7 +57,8 @@ class CDecompressFile
unsigned int ErrorCode; // pokud nastala chyba, tady je uvedeno, jaka
const char* FileName; // nazev archivu, nad kterym pracujem
char* OldName; // puvodni nazev souboru pred zapakovanim
CQuadWord InputSize; // velikost archivu
CQuadWord InputSize; // velikost archivu (parcialni)
CQuadWord InputPos; // pozice v archivu (parcialni)
CQuadWord StreamPos; // pozice v archivu (pro progress)
HANDLE File; // otevreny archiv
DWORD LastError; // pokud byla chyba systemu (I/O...), tady je blizsi urceni
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/tar/lzma/liblzma-port.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
a minimalistic lzma library port
================================

source: https://tukaani.org/xz/
version: 5.4.4
license: public domain

the port contains:
- library sources \src\common and \src\liblzma
- MSVC project file liblzma.vcxproj and config.h, taken from \windows\vz2019 and modified,
- license and readme files
39 changes: 39 additions & 0 deletions src/plugins/tar/lzma/liblzma/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Authors of XZ Utils
===================

XZ Utils is developed and maintained by Lasse Collin
<lasse.collin@tukaani.org> and Jia Tan <jiat0218@gmail.com>.

Major parts of liblzma are based on code written by Igor Pavlov,
specifically the LZMA SDK <https://7-zip.org/sdk.html>. Without
this code, XZ Utils wouldn't exist.

The SHA-256 implementation in liblzma is based on the code found from
7-Zip <https://7-zip.org/>, which has a modified version of the SHA-256
code found from Crypto++ <https://www.cryptopp.com/>. The SHA-256 code
in Crypto++ was written by Kevin Springle and Wei Dai.

Some scripts have been adapted from gzip. The original versions
were written by Jean-loup Gailly, Charles Levert, and Paul Eggert.
Andrew Dudman helped adapting the scripts and their man pages for
XZ Utils.

The initial version of the threaded .xz decompressor was written
by Sebastian Andrzej Siewior.

The initial version of the .lz (lzip) decoder was written
by Michał Górny.

CLMUL-accelerated CRC code was contributed by Ilya Kurdyukov.

Other authors:
- Jonathan Nieder
- Joachim Henke

The GNU Autotools-based build system contains files from many authors,
which I'm not trying to list here.

Several people have contributed fixes or reported bugs. Most of them
are mentioned in the file THANKS.

65 changes: 65 additions & 0 deletions src/plugins/tar/lzma/liblzma/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

XZ Utils Licensing
==================

Different licenses apply to different files in this package. Here
is a rough summary of which licenses apply to which parts of this
package (but check the individual files to be sure!):

- liblzma is in the public domain.

- xz, xzdec, and lzmadec command line tools are in the public
domain unless GNU getopt_long had to be compiled and linked
in from the lib directory. The getopt_long code is under
GNU LGPLv2.1+.

- The scripts to grep, diff, and view compressed files have been
adapted from gzip. These scripts and their documentation are
under GNU GPLv2+.

- All the documentation in the doc directory and most of the
XZ Utils specific documentation files in other directories
are in the public domain.

- Translated messages are in the public domain.

- The build system contains public domain files, and files that
are under GNU GPLv2+ or GNU GPLv3+. None of these files end up
in the binaries being built.

- Test files and test code in the tests directory, and debugging
utilities in the debug directory are in the public domain.

- The extra directory may contain public domain files, and files
that are under various free software licenses.

You can do whatever you want with the files that have been put into
the public domain. If you find public domain legally problematic,
take the previous sentence as a license grant. If you still find
the lack of copyright legally problematic, you have too many
lawyers.

As usual, this software is provided "as is", without any warranty.

If you copy significant amounts of public domain code from XZ Utils
into your project, acknowledging this somewhere in your software is
polite (especially if it is proprietary, non-free software), but
naturally it is not legally required. Here is an example of a good
notice to put into "about box" or into documentation:

This software includes code from XZ Utils <https://tukaani.org/xz/>.

The following license texts are included in the following files:
- COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1
- COPYING.GPLv2: GNU General Public License version 2
- COPYING.GPLv3: GNU General Public License version 3

Note that the toolchain (compiler, linker etc.) may add some code
pieces that are copyrighted. Thus, it is possible that e.g. liblzma
binary wouldn't actually be in the public domain in its entirety
even though it contains no copyrighted code from the XZ Utils source
package.

If you have questions, don't hesitate to ask the author(s) for more
information.

Loading