From 76cfb598bbcb7d13f4e387d1fd25392e0fa09f54 Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Sun, 30 Nov 2025 20:29:41 +0900
Subject: tdeio_iso: add support for xz archives. Code taken from krusader's
 tdeio_iso.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 tdeioslave/iso/iso.cpp     |  2 +-
 tdeioslave/iso/kiso.cpp    | 28 +++++++++++++++++++---------
 tdeioslave/iso/qfilehack.h |  2 +-
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/tdeioslave/iso/iso.cpp b/tdeioslave/iso/iso.cpp
index b088dbb6a..40a7eb738 100644
--- a/tdeioslave/iso/iso.cpp
+++ b/tdeioslave/iso/iso.cpp
@@ -274,7 +274,7 @@ void tdeio_isoProtocol::listDir( const KURL & url )
     const KArchiveDirectory* dir;
     if (!path.isEmpty() && path != "/")
     {
-        kdDebug()   << TQString(TQString("Looking for entry %1").arg(path)) << endl;
+        kdDebug()   << TQString("Looking for entry %1").arg(path) << endl;
         const KArchiveEntry* e = root->entry( path );
         if ( !e )
         {
diff --git a/tdeioslave/iso/kiso.cpp b/tdeioslave/iso/kiso.cpp
index fdd2df413..bcc11810d 100644
--- a/tdeioslave/iso/kiso.cpp
+++ b/tdeioslave/iso/kiso.cpp
@@ -16,7 +16,7 @@
  ***************************************************************************/
 
  /* This file is heavily based on ktar.cpp from tdelibs (c) David Faure */
- 
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -125,6 +125,8 @@ KIso::KIso( const TQString& filename, const TQString & _mimetype )
             mimetype = "application/x-gzip";
         else if ( mimetype == "application/x-tbz" ) // that's a bzipped2 tar file, so ask for bz2 filter
             mimetype = "application/x-bzip2";
+        else if ( mimetype == "application/x-txz" ) // that's a xzipped tar file, so ask for xz filter
+            mimetype = "application/x-xz";
         else
         {
             // Something else. Check if it's not really gzip though (e.g. for KOffice docs)
@@ -144,6 +146,14 @@ KIso::KIso( const TQString& filename, const TQString & _mimetype )
                     if ( fourthByte == 4 )
                         mimetype = "application/x-zip";
                 }
+                else if ( firstByte == 0xfd && secondByte == '7' && thirdByte == 'z' )
+                {
+                    unsigned char fourthByte = file.getch();
+                    unsigned char fifthByte = file.getch();
+                    unsigned char sixthByte = file.getch();
+                    if ( fourthByte == 'X' && fifthByte == 'Z' && sixthByte == 0)
+                        mimetype = "application/x-xz";
+                }
             }
         }
         forced = false;
@@ -155,13 +165,13 @@ KIso::KIso( const TQString& filename, const TQString & _mimetype )
 void KIso::prepareDevice( const TQString & filename,
                             const TQString & mimetype, bool forced )
 {
-  /* 'hack' for Qt's false assumption that only S_ISREG is seekable */
+  /* 'hack' for TQt's false assumption that only S_ISREG is seekable */
   if( "inode/blockdevice" == mimetype )
       setDevice( new QFileHack( filename ) );
   else
   {
-    if( "application/x-gzip" == mimetype
-       || "application/x-bzip2" == mimetype)
+    if("application/x-gzip" == mimetype || "application/x-bzip2" == mimetype ||
+       "application/x-xz" == mimetype)
         forced = true;
 
     TQIODevice *dev = KFilterDev::deviceForFile( filename, mimetype, forced );
@@ -295,7 +305,7 @@ void KIso::addBoot(struct el_torito_boot_descriptor* bootdesc) {
     boot_entry *be;
     TQString path;
     KIsoFile *entry;
-    
+
     entry=new KIsoFile( this, "Catalog", dirent->permissions() & ~S_IFDIR,
         dirent->date(), dirent->adate(), dirent->cdate(),
         dirent->user(), dirent->group(), TQString::null,
@@ -327,7 +337,7 @@ void KIso::readParams()
     TDEConfig *config;
 
     config = new TDEConfig("tdeio_isorc");
-    
+
     showhidden=config->readBoolEntry("showhidden",false);
     showrr=config->readBoolEntry("showrr",true);
     delete config;
@@ -373,7 +383,7 @@ bool KIso::openArchive( int mode )
     if (trackno==0) trackno=1;
     for (i=0;i<trackno;i++) {
 
-        c_b=1;c_i=1;c_j=1;       
+        c_b=1;c_i=1;c_j=1;
         root=rootDir();
         if (trackno>1) {
             path=TQString::null;
@@ -397,11 +407,11 @@ bool KIso::openArchive( int mode )
                     if ( !memcmp(EL_TORITO_ID,bootdesc->system_id,ISODCL(8,39)) ) {
                         path="El Torito Boot";
                         if (c_b>1) path += " (" + TQString::number(c_b) + ")";
-                        
+
                         dirent = new KIsoDirectory( this, path, access | S_IFDIR,
                             buf.st_mtime, buf.st_atime, buf.st_ctime, uid, gid, TQString::null );
                         root->addEntry(dirent);
-                        
+
                         addBoot(bootdesc);
                         c_b++;
                     }
diff --git a/tdeioslave/iso/qfilehack.h b/tdeioslave/iso/qfilehack.h
index 3f0b1f6a6..fe43217b2 100644
--- a/tdeioslave/iso/qfilehack.h
+++ b/tdeioslave/iso/qfilehack.h
@@ -23,7 +23,7 @@
 
 /**
   *@author Szombathelyi György
-  * Qt thinks if a file is not S_IFREG, you cannot seek in it. It's false (what about
+  * TQt thinks if a file is not S_IFREG, you cannot seek in it. It's false (what about
   * block devices for example?
   */
 
-- 
cgit v1.2.3

