Wrapper for SQX Archiver (PB4 win only)

Share your advanced PureBasic knowledge/code with the community.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Wrapper for SQX Archiver (PB4 win only)

Post by ts-soft »

Code updated for 5.20+

Code: Select all

;********************** 
; Author: Thomas  (ts-soft) Schulz
; Date: 29. Januar 2007
; OS: Windows
; Demo: Yes

; Description: Wrapper for "sqx20.dll" and "sqx20u.dll" Packdll
; SDK download: http://www.sqx-archiver.de/index.html
;********************** 
; 
;{ Constants
Enumeration 0         ; Error Codes
  #SQX_ERR_SUCCESS                       ; No error.
  #SQX_ERR_ERROR                         ; Unknown error in the last archive operation.
  #SQX_ERR_FILE_NOT_FOUND                ; The system cannot find the file specified.
  #SQX_ERR_PATH_NOT_FOUND                ; The system cannot find the path specified.
  #SQX_ERR_TOO_MANY_FILES                ; The system cannot open the file.
  #SQX_ERR_ACCESS_DENIED                 ; Access is denied.
  #SQX_ERR_INVALID_HANDLE                ; The file handle is invalid.
  #SQX_ERR_DISK_FULL                     ; The disk is full.
  #SQX_ERR_OUT_OF_MEMORY                 ; Not enough memory is available to complete this operation.
  #SQX_ERR_CANT_ACCESS_TEMP_DIR          ; Cannot access temp folder during a delete or update operation on a solid archive.
  #SQX_ERR_TEMP_DIR_FULL                 ; Not enough space on drive for the temporary folder.
  #SQX_ERR_USER_ABORT                    ; Cancelled by user.
  #SQX_ERR_INVALID_ARC_HANDLE            ; Invalid archive handle.
  #SQX_ERR_CANT_FIND_LANG_DATA           ; Could not find the selected language file for self-extracting archives.
  #SQX_ERR_UNKNOWN_SUBSTREAM             ; The archive contains at least one unknown alternate data stream.
  #SQX_ERR_BAD_SUBSTREAM_CRC             ; Bad alternate stream CRC. Archive is probably corrupted.
  #SQX_ERR_UNKNOWN_METHOD                ; This method of compression is not supported by the archiver.
  #SQX_ERR_FILE_ENCRYPTED                ; Archive is encrypted with a password.
  #SQX_ERR_BAD_CRC                       ; Bad CRC. Archive is probably corrupted.
  #SQX_ERR_CANT_CREATE_FILE              ; Could not create file or folder.
  #SQX_ERR_BAD_FILE_FORMAT               ; Bad archive file format.
  #SQX_ERR_FUNCTION_NOT_SUPPORTED        ; Function is not supported.
  #SQX_ERR_FUNC_NOT_SUPPORTED_BY_ARCHIVE ; Function is not supported for this archive type.
  #SQX_ERR_CANT_CREATE_ARC_DIR           ; Could not create folder in archive. It already exists a folder with this name.
  #SQX_ERR_INVALID_DIR_NAME              ; Could not create folder in archive. The folder name contains invalid characters.
  #SQX_ERR_INVALID_FILE_NAME             ; Could not create file in archive. The file name contains invalid characters.
  #SQX_ERR_TOO_MANY_BROKEN_FBLOCKS       ; The archive file contains too many damaged file blocks and cannot be repaired.
  #SQX_ERR_ARCHIVE_OK_RDATA_NOT          ; It seems that the archive has no errors, but the recovery data does not match the archive. Maybe this archive was edited by a program that could not identify the recovery data.
  #SQX_ERR_RDATA_DAMAGED                 ; The recovery data of the archive file is damaged, too. This archive file cannot be repaired.
  #SQX_ERR_RDATA_NEW_VERSION             ; The archive contains recovery data that cannot be used with this version of our software. The newest versions of our software are always available at http://www.speedproject.de/.
  #SQX_ERR_RDATA_DOES_NOT_MATCH          ; The recovery data does not match the archive. It seems that this archive was edited by a program that could not identify the recovery data.
  #SQX_ERR_CANT_FIND_RDATA               ; It seems that the archive does not contain any recovery data.
  #SQX_ERR_ARCHIVE_IS_LOCKED             ; Cannot modify locked archive.
  #SQX_ERR_CANT_ADD_TO_MV                ; It is not possible to add files to a multi-volume archive.
  #SQX_ERR_CANT_DELETE_FROM_MV           ; It is not possible to delete files from a multi-volume archive.
  #SQX_ERR_NEED_1ST_VOLUME               ; This file is part of a multi-volume archive. The first volume of the archive is needed to open it. Please select the first volume to open the archive.
  #SQX_ERR_MISSING_VOLUME                ; The last volume of the archive could not be found.
  #SQX_ERR_VOLUME_LIMIT_REACHED          ; Cannot create more than 999 volumes.
  #SQX_ERR_SFXSTUB_NOT_INSTALLED         ; This system lacks the support for the SFX type you have selected. Please visit the download section of http://ww.speedproject.de/ to obtain complete support for SFX archives.
  #SQX_ERR_BACKUP_READ_ACCESS_DENIED     ; Read access to alternate data stream was denied. Only the file itself is being compressed.
  #SQX_ERR_BACKUP_WRITE_ACCESS_DENIED    ; Could not write alternate data stream (e.g. file comments).
  #SQX_ERR_ACL_READ_ACCESS_DENIED        ; Could not read security attributes. Only the file itself is being compressed.
  #SQX_ERR_ACL_WRITE_ACCESS_DENIED       ; Could not write security attributes.
  #SQX_ERR_WRONG_ARCHIVER_VERSION        ; This archive contains data created with a higher version of this software. Please download the lastest update of the software from http://www.speedproject.de/.
  #SQX_ERR_CANT_COPY_SOURCE_TO_SOURCE    ; Cannot copy an archive to itself. Please choose a different target name.
  #SQX_ERR_VOLUMES_TOO_SMALL             ; The volume size cannot be smaller than 130 kByte.
  #SQX_ERR_ARCHIVE_VERSION_TOO_HIGH      ; This archive can only be extracted. It is not possible to add files.
  #SQX_ERR_EXT_RDATA_DOES_NOT_MATCH      ; The external recovery data don't seem to belong to the selected archive.
  #SQX_ERR_BAD_PARAMETER                 ; The parameter is incorrect.
  #SQX_ERR_EQUAL_PASSWORDS               ; The passwords for the archive files and archive directory are identical. Please enter different passwords.
  #SQX_ERR_REQUIRES_ENCRYPTION           ; You cannot encrypt the archive directory without encrypting the files. Please enter one password for the archive directory and another password for the files.
  #SQX_ERR_MISSING_HEADER_PASSWORD       ; Please enter a password to encrypt the archive directory.
  #SQX_ERR_MISSING_SQX_PRIVATE_KEY       ; Could not find/access the private key required to encrypt the archive. Please make sure that the software can access all the keys in question.
  #SQX_ERR_MISSING_SQX_AVKEY             ; Could not find the key required to create a digital signature. Please make sure that the software can access the authentication key.
  #SQX_ERR_MISSING_EXTERNAL_AVKEY        ; Could not find/access the external key necessary to sign the archive. Please make sure that the software can access all keys in question.
  #SQX_ERR_INVALID_SQX_AVKEY             ; The key you have selected to create digital signatures is invalid.
  #SQX_ERR_SQX_AVKEY_VERSION             ; This version of the software cannot use the existing key to create digital signatures. Please download the lastest update of the software from http://www.speedproject.de/.
  #SQX_ERR_SQX_AVDATA_VERSION            ; This version of the software cannot process the digital signature embedded within the archive. Please download the lastest update of the software from http://www.speedproject.de/.
  #SQX_ERR_SQX_BROKEN_AVRECORD           ; The archive contains an invalid digital signature. The archive is either damaged or it has been manipulated.
  #SQX_ERR_RIJNDAEL_RSA                  ; Unexpected error in an encryption function. Please contact our product support.
  #SQX_ERR_REQUIRES_NTFS                 ; An option you selected requires NTFS.
  #SQX_ERR_REQUIRES_WINNT                ; An option you selected requires Windows NT.
  #SQX_ERR_REQUIRES_W2K                  ; An option you selected requires Windows 2000.
  #SQX_ERR_REQUIRES_WINXP                ; An option you selected requires Windows XP.
  #SQX_ERR_REQUIRES_WINXP_SP1            ; An option you selected requires Windows XP SP1.
  #SQX_ERR_REQUIRES_WINXP_SP2            ; An option you selected requires Windows XP SP2.
  #SQX_ERR_REQUIRES_LONGHORN             ; An option you selected requires Longhorn.
  #SQX_ERR_NO_RESOURCES_FOUND            ; The selected SFX stub does not contain resources. Can not modify SFX stub.
  #SQX_ERR_UNKNOWN_ICON_FORMAT           ; Could not determine the format of the selected icon file.
  #SQX_ERR_NO_MATCHING_ICON_SIZE         ; The selected SFX stub does not contain icons with valid sizes. Can not modify SFX stub.
  #SQX_ERR_UNKNOWN_EXE_FORMAT            ; The format of the selected SFX stub is unknown.
  #SQX_ERR_REQUIRES_SOURCE_PATH          ; The extended archive test requires the source path.
  #SQX_ERR_FILE_DATA_NOT_EQUAL           ; Extended archive test: The source on hard disk is different from the file in the archive.
  #SQX_ERR_COMMENT_BIGGER_4K             ; You cannot add to the archive comments longer than 4096 chars. Please shorten your comments and try again.
  #SQX_ERR_CANT_CREATE_SFX_FROM_MV       ; Cannot create a self-extracting archive from a multi-volume archive.
EndEnumeration
Enumeration 0         ; SQX_AVENVELOPE
  #SQX_AVENVELOPE_128BIT ; Envelope is calculated with 128 bit (fastest)
  #SQX_AVENVELOPE_256BIT ; Envelope is calculated with 256 bit (fast)
  #SQX_AVENVELOPE_512BIT ; Envelope is calculated with 512 bit (securest)
EndEnumeration
Enumeration 0         ; SQX_CALLBACK
  #SQX_CALLBACK_FILENAME        ; SQX archiver is about to compress, extract, delete or test a file
  ; MEMBERS: pszSourceFileName, pszTargetFileName
  #SQX_CALLBACK_PROGRESS        ; SQX archiver signals the progress of a file beeing compressed, extracted or tested
  ; MEMBERS: iProgress, dwlBlockSize
  #SQX_CALLBACK_REPLACE         ; SQX archiver is about to overwrite either a file on disk (when extracting) or a file in the archive (when compressing)
  ; MEMBERS: pFindDataExist,
  #SQX_CALLBACK_PASSWORD        ; SQX archiver needs a password to decrypt a file
  ; MEMBERS: szCryptKey, szOldCryptKey
  #SQX_CALLBACK_PASSWORD_HEADER ; SQX archiver needs a password to decrypt the archive directory
  ; MEMBERS: szCryptKey, szOldCryptKey
  #SQX_CALLBACK_SKIP            ; SQX archiver cannot open a file because it is locked by another application
  ; MEMBERS: pszSourceFileName
  #SQX_CALLBACK_NEXTDISK        ; SQX archiver needs the next volume when extracting or a new disk when compressing
  ; MEMBERS: dwTotalSize, dwDiskNum, szNextDiskPath
  #SQX_CALLBACK_SIGNAL          ; SQX archiver signals the next command
  ; MEMBERS: dwSignal, dwlBlockSize
EndEnumeration
Enumeration 0         ; SQX_COMPRATE
  #SQX_COMPRATE_STORED    ; No compression
  #SQX_COMPRATE_FAST      ; Fast compression
  #SQX_COMPRATE_NORMAL    ; Normal compression
  #SQX_COMPRATE_HIGH      ; High compression
  #SQX_COMPRATE_MAXIMIUM  ; Maximum compression
  #SQX_COMPRATE_ULTRA     ; Ultra compression
EndEnumeration
Enumeration 0         ; Specialcomp
  #SQX_SPECIALCOMP_DISABLED
  #SQX_SPECIALCOMP_AUTOMATIC
  #SQX_SPECIALCOMP_FORCE
EndEnumeration
Enumeration 3         ; SQX_DICTIONARY
  #SQX_DICTIONARY_32K   ; 32 KB dictionary size
  #SQX_DICTIONARY_64K   ; 64 KB dictionary size
  #SQX_DICTIONARY_128K  ; 128 KB dictionary size
  #SQX_DICTIONARY_256K  ; 256 KB dictionary size
  #SQX_DICTIONARY_512K  ; 512 KB dictionary size
  #SQX_DICTIONARY_1M    ; 1 MB dictionary size
  #SQX_DICTIONARY_2M    ; 2 MB dictionary size
  #SQX_DICTIONARY_4M    ; 4 MB dictionary size
  #SQX_DICTIONARY_8M    ; 8 MB dictionary size
  #SQX_DICTIONARY_16M   ; 16 MB dictionary size
  #SQX_DICTIONARY_32M   ; 32 MB dictionary size
EndEnumeration
Enumeration 0 Step 2  ; SQX_ENCRYPTION
  #SQX_ENCRYPTION_NONE        ; Files are not encrypted
  #SQX_ENCRYPTION_AES_128BIT  ; Files are encrypted with 128 bit AES
  #SQX_ENCRYPTION_AES_256BIT  ; Files are encrypted with 256 bit AES
EndEnumeration
Enumeration 0         ; SQX_FILEFORMAT
  #SQX_FILEFORMAT_10  ; SQX1 file format
  #SQX_FILEFORMAT_20  ; SQX2 file format
EndEnumeration
Enumeration 0         ; SQX_FILENAME
  #SQX_FILENAME_ANSI    ; File names are stored in ANSI. This is the default value
  #SQX_FILENAME_ASCII   ; File names are converted to ASCII
  #SQX_FILENAME_UNICODE ; File names are stored in ANSI and Unicode. This option is only avalaible in the Unicode version of SQX archiver
EndEnumeration
Enumeration 0         ; SQX_HOSTOS
  #SQX_HOSTOS_DOSWIN        ; DOS/Windows
  #SQX_HOSTOS_DOS           ; DOS
  #SQX_HOSTOS_OS2           ; OS/2
  #SQX_HOSTOS_WIN32         ; Win32
  #SQX_HOSTOS_WINNT         ; Windows NT
  #SQX_HOSTOS_UNIX          ; UNIX
  #SQX_HOSTOS_MAC           ; Mac-OS
  #SQX_HOSTOS_WINNT_ALPHA   ; Windows NT AXP
  #SQX_HOSTOS_ATARI         ; Atari
  #SQX_HOSTOS_VAX_VMS       ; VAX VMS
  #SQX_HOSTOS_AMIGA         ; Amiga
  #SQX_HOSTOS_NEXT          ; Next
  #SQX_HOSTOS_LINUX         ; Linux
  #SQX_HOSTOS_CPM           ; CPM
  #SQX_HOSTOS_ZSYS          ; ZSYS
  #SQX_HOSTOS_VMCMS         ; VMCMS
  #SQX_HOSTOS_BEOS          ; BeOS
  #SQX_HOSTOS_UNKNOWN       ; Unknown
  #SQX_HOSTOS_OS2_HPFS      ; OS/2-HPFS
  #SQX_HOSTOS_WIN32_FAT32   ; Win32 (FAT32)
  #SQX_HOSTOS_WINNT_NTFS    ; Windows NT (NTFS)
  #SQX_HOSTOS_WINNTAXP_NTFS ; Windows NT AXP (NTFS)
  #SQX_HOSTOS_MVS           ; OS/390, Z/OS
  #SQX_HOSTOS_VSE           ; VSE
  #SQX_HOSTOS_ARCORN_RISC   ; Acorn Risc
  #SQX_HOSTOS_MVS_ALT       ; MVS
EndEnumeration
Enumeration 0         ; SQX_METHOD
  #SQX_METHOD_STORED  ; Stored (no compression)
  #SQX_METHOD_NORMAL  ; Compressed, normal compression (LZH)
  #SQX_METHOD_GOOD    ; Compressed, good compression (LZH)
  #SQX_METHOD_HIGH    ; Compressed, high compression (LZH)
  #SQX_METHOD_BEST    ; Compressed, best compression (LZH)
  #SQX_METHOD_AUDIO   ; Compressed, audio (WAV, PCM) compression
  #SQX_METHOD_TEXT    ; Compressed, text compression (PPMD)
  #SQX_METHOD_ULTRA   ; Compressed, ultra compression (LZ77 & RC)
EndEnumeration
Enumeration 0         ; SQX_RECOVERYDATA
  #SQX_RECOVERYDATA_NONE  ; No recovery data are added
  #SQX_RECOVERYDATA_1     ; 1% recovery data are added
  #SQX_RECOVERYDATA_2     ; 2% recovery data are added
  #SQX_RECOVERYDATA_3     ; 3% recovery data are added
  #SQX_RECOVERYDATA_4     ; 4% recovery data are added
  #SQX_RECOVERYDATA_5     ; 5% recovery data are added
EndEnumeration
Enumeration 1         ; SQX_SIGNAL
  #SQX_SIGNAL_COMPRESS            ; Total size in bytes of the data to be compressed
  ; Action: Compressing
  #SQX_SIGNAL_UNCOMPRESS          ; Total size in bytes of the data to be extracted
  ; Action: Extracting
  #SQX_SIGNAL_DELETE              ; Number of files beeing to be deleted
  ; Action: Deleting
  #SQX_SIGNAL_TEMP_ARC_COPY       ; Total size of bytes to be copied
  ; Action: Copying temporary archive
  #SQX_SIGNAL_CREATE_AV_SIG       ; Total size of the archive to be signed
  ; Action: Creating digital signature
  #SQX_SIGNAL_TEST_AV_SIG         ; Total size of the archive to be tested
  ; Action: Testing digital signature
  #SQX_SIGNAL_ADD_MV_UNCOMPRESS   ; Size of the current volume
  ; Action: Extracting multivolume
  #SQX_SIGNAL_CREATE_RDATA        ; Total size of the archive
  ; Action: Creating recovery data
  #SQX_SIGNAL_REPAIR_ARCHIVE      ; Total size of the archive
  ; Action: Repairing archive
  #SQX_SIGNAL_STRIP_RDATA         ; Total size of the archive
  ; Action: Stripping recovery data
  #SQX_SIGNAL_TEST_ARCHIVE        ; Total size of the archive
  ; Action: Testing archive
  #SQX_SIGNAL_CREATE_SFX_ARCHIVE  ; Total size of the archive
  ; Action: Creating a sfx from an existing archive
  #SQX_SIGNAL_ADD_MV_TEST         ; Size of the current volume
  ; Action: Testing multivolume
  #SQX_SIGNAL_EX_TEST_ARCHIVE     ; Total size of the archive to be tested
  ; Action: Extended testing
  #SQX_SIGNAL_ADD_MV_EX_TEST      ; Size of the current volume
  ; Action: Extended testing multivolume
EndEnumeration
Enumeration 0         ; SQX_VOLUMESIZE
  #SQX_VOLUMESIZE_NONE    ; No multivolume archive is created
  #SQX_VOLUMESIZE_360     ; A multivolume archive with a volume size of 360 KB is created
  #SQX_VOLUMESIZE_720     ; A multivolume archive with a volume size of 720 KB is created
  #SQX_VOLUMESIZE_1200    ; A multivolume archive with a volume size of 1.20 MB is created
  #SQX_VOLUMESIZE_1400    ; A multivolume archive with a volume size of 1.44 MB is created
  #SQX_VOLUMESIZE_2000    ; A multivolume archive with a volume size of 2 MB is created
  #SQX_VOLUMESIZE_5000    ; A multivolume archive with a volume size of 5 MB is created
  #SQX_VOLUMESIZE_10000   ; A multivolume archive with a volume size of 10 MB is created
  #SQX_VOLUMESIZE_30000   ; A multivolume archive with a volume size of 30 MB is created
  #SQX_VOLUMESIZE_ZIP100  ; A multivolume archive with a volume size of 100 MB is created
  #SQX_VOLUMESIZE_LS120   ; A multivolume archive with a volume size of 120 MB is created
  #SQX_VOLUMESIZE_ZIP250  ; A multivolume archive with a volume size of 250 MB is created
  #SQX_VOLUMESIZE_CDR650  ; A multivolume archive with a volume size of 650 MB is created
  #SQX_VOLUMESIZE_CDR700  ; A multivolume archive with a volume size of 700 MB is created
EndEnumeration
;}
;{ Structures
Structure SQX_AVINFO
; structure is a member of the SQX_ARCINFO structure and contains information about the AV envelope
  fAVInfoPresent.l
  szAV_ID.s{#MAX_PATH}
  ftCreationTime.q
EndStructure
Structure SQX_ARCINFO
; is used to receive information about a certain SQX archive when listing it
  cbSize.l
  dwFileFormat.l
  dwArcerMajorVersion.l
  dwArcerMinorVersion.l
  dwDictionarySize.l
  fRecoveryData.l
  dwEncryption.l
  fSolid.l
  dwHostOS.l
  dwTotalFiles.l
  dwlCompressedSize.q
  dwlUncompressedSize.q
  iRatio.l
  fHeaderEncrypted.l
  fIsMultiVolume.l
  fArchiveComment.l
  fFileComments.l
  avInfo.SQX_AVINFO
EndStructure
Structure SQX_FILETIME
; structure is a member of the SQX_ARCNODE structure and contains extended time stamps
  fBlockPresent.l
  ftCreationTime.q
  ftLastAccessTime.q
  ftLastWriteTime.q
EndStructure
Structure SQX_ARCNODE
; structure is used to pass information about file properties to the caller when listing an archive. The caller should ignore this node if fTagged is set to FALSE
  pszFileName.s
  dwFileNameLen.l
  pszExtraName.s
  dwExtraNameLen.l
  dwFileNameType.l
  dwlSize.q
  dwlSizeOrig.q
  dwDosFileTime.l
  dwAttributes.l
  dwArcerVersion.l
  dwFileCRC.l
  dwHostOS.l
  dwMethod.l
  dwCommentLen.l
  pszComment.s
  fEncrypted.l
  fTagged.l
  dwMappedMethod.l
  dwExtendedError.l
  win32FileTime.SQX_FILETIME
EndStructure
Structure SQX_CALLBACKINFO
; structure is by SQX archiver to signal the caller that a certain command is executed or that a certain action needs user interaction, for example when a file is going to be overwritten or when SQX archiver needs a password to decrypt files
  dwCallbackType.l
  pszSourceFileName.s
  pszTargetFileName.s
  iProgress.l
  *pFindDataExist.WIN32_FIND_DATA
  *pFindDataReplace.WIN32_FIND_DATA
  szCryptKey.s{#MAX_PATH}
  szOldCryptKey.s{#MAX_PATH}
  szCryptFileName.s{#MAX_PATH}
  dwTotalSize.l
  dwDiskNum.l
  szNextDiskPath.s{#MAX_PATH}
  dwSignal.l
  dwlBlockSize.q
EndStructure
Structure SQX_FORCECOMP
; structure is a member of the SQX_COMPRESSOPTIONS structure. It is used to control the core compression settings
  dwCompRate.l
  fSolidFlag.l
  dwDictionarySize.l
  dwExeCompression.l
  dwTextCompression.l
  dwTextMemory.l
  dwTextOrder.l
  dwMultimediaCompression.l
  dwMultimediaChannels.l
  dwAudioCompression.l
  dwAudioChannels.l
  dwAudioChannelsWidth.l
  dwRgbCompression.l
  dwUltraMatchLink.l
EndStructure
Structure SQX_VERSIONINFO
; structure is a member of the SQX_SFXCOMMAND structure and contains optional information about version information for the self-extracting ar
  szLegalCopyright.s{40}
  szCompanyName.s{40}
  szFileDescription.s{40}
  szFileVersion.s{40}
  szProductName.s{40}
  szProductVersion.s{40}
EndStructure
Structure SQX_SFXCOMMAND
; structure is a member of the SQX_COMPRESSOPTIONS structure. It is used to control the settings of the SFX stubs provided with the SQX SDK
  fCreateSfx.l
  dwType.l
  dwSystem.l
  szHintTitle.s{256}
  szHintMsg.s{4096}
  dwHintBtn.l
  szInfoAboutMsg.s{256}
  szNormalFolder.s{#MAX_PATH}
  szNormalCmd.s{#MAX_PATH}
  fNormalOverwriteWOPrompt.l
  fNormalAutoExtract.l
  szInstallMsg.s{256}
  szInstallCmd.s{#MAX_PATH}
  szInstallWaitFor.s{#MAX_PATH}
  szIconFile.s{#MAX_PATH}
  szLanguageFile.s{#MAX_PATH}
  versionInfo.SQX_VERSIONINFO;
EndStructure
Structure SQX_COMPRESSOPTIONS
; structure is used to control several settings of SQX archiver when adding files to archives
  cbSize.l
  dwFileFormat.l
  compOptions.SQX_FORCECOMP
  sfxCommand.SQX_SFXCOMMAND
  dwRecoveryData.l
  fExternalRecoveryData.l
  pszMainComment.s
  dwEncryption.l
  fEncryptHeaders.l
  fAVSignature.l
  fAVSignatureExternal.l
  dwAVEnvelope.l
  szSignatureFile.s{#MAX_PATH}
  szPassword.s{#MAX_PATH}
  szPasswordHeader.s{#MAX_PATH}
  fRetainFolderStructure.l
  fRetainDrivePart.l
  szRelativePath.s{#MAX_PATH}
  szInputPath.s{#MAX_PATH}
  dwFileNames.l
  fStoreWin32FileTime.l
  fStoreACL.l
  fStoreStreams.l
  fAutoSaveComments.l
  fExtendedTest.l
  szTempDir.s{#MAX_PATH}
  dwlVolumeSize.q
  fAutoVolumeSize.l
  fCreateAlwaysNewArchive.l
  fResetArchiveAttribute.l
  dwLogType.l
EndStructure
Structure SQX_EXTRACTOPTIONS
; structure is used to control several settings of SQX archiver when extracting files from archives
  cbSize.l
  szPassword.s{#MAX_PATH}
  szPasswordHeader.s{#MAX_PATH}
  szTempDir.s{#MAX_PATH}
  szRelativePath.s{#MAX_PATH}
  szOutputPath.s{#MAX_PATH}
  fResetArchiveAttribute.l
  fOverwriteAlways.l
  fKeepBrokenFiles.l
  fCreateFolders.l
  fRestoreACLs.l
  fRestoreStreams.l
  fRestoreUnicodeNames.l
  fRestoreWin32FileTimes.l
  fRestoreDirectoryTimeStamps.l
  fAutoRestoreComments.l
  fSetZoneID.l
EndStructure
Structure SQX_ARCLISTNODE
; structure is used to pass information about file properties to the caller when listing an archive
  *pNext.SQX_ARCLISTNODE;
  *pArcNode.SQX_ARCNODE;
EndStructure
Structure SQX_ARCLIST
;  structure is used to pass information about file properties to the caller when listing an archive structure is used to pass information about file properties to the caller when listing an archive
  dwItemCount.l
  *pHead.SQX_ARCLISTNODE;
  *pTail.SQX_ARCLISTNODE;
EndStructure
;}
;{ Prototypes
Prototype.l SqxInitArchive(pszArchiveName.s, Callback.l, *pParam, phArchiver.l)
Prototype.l SqxDoneArchive(hArchive.l)
Prototype.l SqxInitFileList(hArchive.l)
Prototype.l SqxAppendFileList(hArchive.l, hFileMaskList.l, pszFileName.s)
Prototype.l SqxDoneFileList(hArchive.l, hFileMaskList.l)
Prototype.l SqxInitArcFileList(hArchive.l)
Prototype.l SqxDoneArcFileList(hArchive.l, *pList)
Prototype.l SqxListFiles(hArchive.l, hFileMaskList.l, *pArcFileList, pArchiveInfo.l)
Prototype.l SqxCompressFiles(hArchive.l, *pfnCallback, *pParam, hFileMaskList.l, *pCompressOptions)
Prototype.l SqxExtractFiles(hArchive.l, *pfnCallback, *pParam, hFileMaskList.l, *pExtractOptions)
Prototype.l SqxDeleteFiles(hArchive.l, *pfnCallback, *pParam, hFileMaskList.l)
Prototype.l SqxTestArchive(hArchive.l, *pfnCallback, *pParam)
Prototype.l SqxRepairArchive(hArchive.l, pszRepairedFile.s, *pGoodFileList, *pBadFileList)
Prototype.l SqxAddArchiveComment(hArchive.l, pszMainComment.s)
Prototype.l SqxGetArchiveComment(hArchive.l, pszMainComment.s, cchMainComment.l)
Prototype.l SqxAddFileComments(hArchive.l, hFileMaskList.l, pszComment.s)
Prototype.l SqxCreateFolder(hArchive.l,pszFolder.s)
;}
; Initfunction
Procedure Sqx_Init(DLLName.s = "")
  Protected Lib.l
  If DLLName = ""
    CompilerIf #PB_Compiler_Unicode
      DLLName = "sqx20u.dll"
    CompilerElse
      DLLName = "sqx20.dll"
    CompilerEndIf
  EndIf

  Lib = OpenLibrary(#PB_Any, DLLName)
  If Lib <> 0
    Global SqxInitArchive.SqxInitArchive             = GetFunction(Lib, "SqxInitArchive")
    Global SqxDoneArchive.SqxDoneArchive             = GetFunction(Lib, "SqxDoneArchive")
    Global SqxInitFileList.SqxInitFileList           = GetFunction(Lib, "SqxInitFileList")
    Global SqxAppendFileList.SqxAppendFileList       = GetFunction(Lib, "SqxAppendFileList")
    Global SqxDoneFileList.SqxDoneFileList           = GetFunction(Lib, "SqxDoneFileList")
    Global SqxInitArcFileList.SqxInitArcFileList     = GetFunction(Lib, "SqxInitArcFileList")
    Global SqxDoneArcFileList.SqxDoneArcFileList     = GetFunction(Lib, "SqxDoneArcFileList")
    Global SqxListFiles.SqxListFiles                 = GetFunction(Lib, "SqxListFiles")
    Global SqxCompressFiles.SqxCompressFiles         = GetFunction(Lib, "SqxCompressFiles")
    Global SqxExtractFiles.SqxExtractFiles           = GetFunction(Lib, "SqxExtractFiles")
    Global SqxDeleteFiles.SqxDeleteFiles             = GetFunction(Lib, "SqxDeleteFiles")
    Global SqxTestArchive.SqxTestArchive             = GetFunction(Lib, "SqxTestArchive")
    Global SqxRepairArchive.SqxRepairArchive         = GetFunction(Lib, "SqxRepairArchive")
    Global SqxAddArchiveComment.SqxAddArchiveComment = GetFunction(Lib, "SqxAddArchiveComment")
    Global SqxGetArchiveComment.SqxGetArchiveComment = GetFunction(Lib, "SqxGetArchiveComment")
    Global SqxAddFileComments.SqxAddFileComments     = GetFunction(Lib, "SqxAddFileComments")
    Global SqxCreateFolder.SqxCreateFolder           = GetFunction(Lib, "SqxCreateFolder")
  EndIf

  ProcedureReturn Lib
EndProcedure
Last edited by ts-soft on Mon Jan 29, 2007 9:41 am, edited 2 times in total.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

small example:

Code: Select all

XIncludeFile "SQX_Include.pbi"

Define.l hArchive, hFileMaskList, error
Define.SQX_COMPRESSOPTIONS compressOptions

If Sqx_Init()
  error = SqxInitArchive("C:\test.sqx", 0, 0, @hArchive.l)
  If Not Error
    hFileMaskList = SqxInitArcFileList(hArchive)
    If hFileMaskList
      SqxAppendFileList(hArchive, hFileMaskList, "Gadget.pb")
      SqxAppendFileList(hArchive, hFileMaskList, "GadgetAdvanced.pb")
      SqxAppendFileList(hArchive, hFileMaskList, "GadgetSplitter.pb")

      ;Compress options
      compressOptions\cbSize = SizeOf(SQX_COMPRESSOPTIONS)
      ; Create SQX2 archive
      compressOptions\dwFileFormat = #SQX_FILEFORMAT_20
      ; Core compression options
      compressOptions\compOptions\dwCompRate = #SQX_COMPRATE_MAXIMIUM
      compressOptions\compOptions\dwDictionarySize = #SQX_DICTIONARY_4M
      compressOptions\compOptions\fSolidFlag = #True
      ; Extended compression options
      compressOptions\compOptions\dwExeCompression = #SQX_SPECIALCOMP_AUTOMATIC
      compressOptions\compOptions\dwRgbCompression = #SQX_SPECIALCOMP_AUTOMATIC
      compressOptions\compOptions\dwTextCompression = #SQX_SPECIALCOMP_AUTOMATIC
      compressOptions\compOptions\dwAudioCompression = #SQX_SPECIALCOMP_AUTOMATIC
      compressOptions\compOptions\dwMultimediaCompression = #SQX_SPECIALCOMP_AUTOMATIC
      ; Additional options
      compressOptions\fRetainFolderStructure = #True
      ; Source path for the files to be compressed
      compressOptions\szInputPath = #PB_Compiler_Home + "Examples\Sources\"

      error = SqxCompressFiles(hArchive, 0, 0, hFileMaskList, @compressOptions)
      If Not error
        SqxDoneArcFileList(hArchive, hFileMaskList)
      Else
        Debug error
      EndIf
    EndIf
    SqxDoneArchive(hArchive)
  Else
    Debug error
  EndIf
EndIf
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

This is really cool! Thanks!
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Beat me to it :lol: :lol: :lol:

Nice work... Very interesting compression format!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

thanks,
i think, it's more easy than zlib :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Max
User
User
Posts: 67
Joined: Thu Nov 30, 2006 4:57 pm
Location: I long for the absolute loneliness of the death

Post by Max »

COOL!

How to add a folder and its files?.
SqxCreateFolder seems not work.

Try:

Code: Select all

      SqxAppendFileList(hArchive, hFileMaskList, "MyFolder")
      ExamineDirectory(1,"MyFolder","*.*")
      while NextDirectoryEntry(1)
        file.s = GetFilePart(DirectoryEntryName(1))
        if left(file,1) <> "."
          SqxAppendFileList(hArchive, hFileMaskList, "MyFolder\"+file)
        endif
      wend
      FinishDirectory(1)
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

@Ts-Soft, could you please post a decompression example (if you have any free time)? I can't get it to decompress an archive...
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Inf0Byt3 wrote:@Ts-Soft, could you please post a decompression example (if you have any free time)? I can't get it to decompress an archive...
Please see in the sdk

I have made a small examples for unpack, but doesn't work :? in the moment. Don't know what's wrong.

Code: Select all

XIncludeFile "SQX_Include.pbi"

Define.l error, hFileMaskList, hArchive
Define.SQX_EXTRACTOPTIONS extractOption
 
If Sqx_Init()
  error = SqxInitArchive("C:\test.sqx", 0, 0, @hArchive)
  If hFileMaskList
    SqxAppendFileList(hArchive, hFileMaskList, "*.*")
    extractOption.SQX_EXTRACTOPTIONS
    extractOption\cbSize = SizeOf(SQX_EXTRACTOPTIONS)
    extractOption\szOutputPath = "C:"
    extractOption\fCreateFolders = #True
    error = SqxExtractFiles(hArchive, 0, 0, hFileMaskList, @extractOption)
    If Not error
      SqxDoneArcFileList(hArchive, hFileMaskList)
    Else
      Debug error
    EndIf
    SqxDoneArchive(hArchive)
  Else
    Debug error
  EndIf
EndIf
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Hmm... that's strange... I made the exactly same code and tried to decompress, but it didn't work, that's why I asked for help... Maybe we must set all the flags ?? I'll read the SDK docs and if I get any results I'll post here.

Thank you!

Code: Select all

CSqxArchiveDll archiveDll;
if (archiveDll.LoadArchiveDll())
{
    int iStatus = archiveDll.InitArchive(_T("C:\\test.sqx"), SqxCallback, this);
    if (SQX_ERR_SUCCESS == iStatus)
    {
        // Create a file list
        HANDLE hFileMaskList = archiveDll.InitFileList();

        // Extracting all files
        archiveDll.AppendFileList(hFileMaskList, _T("*.*"));

        // Extract options
        SQX_EXTRACTOPTIONS extractOptions; ZeroMemory(&extractOptions, sizeof(extractOptions));
        extractOptions.cbSize = sizeof(extractOptions);

        // Extract to C:\Test		
        lstrcpy(extractOptions.szOutputPath, _T("C:\\Test"));
        extractOptions.fCreateFolders = TRUE;
		
        // Extract the archive
        iStatus = archiveDll.ExtractFiles(SqxCallback, this, hFileMaskList, &extractOptions);
        if (SQX_ERR_SUCCESS != iStatus)
        {
           // Error 
        }

        // Free the file list
        archiveDll.DoneFileList(hFileMaskList);
    }

    // Close the archive
    archiveDll.DoneArchive();
}


I'll investigate this, it's from the SDK...
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

I think, it's a problem with the SQX_EXTRACTOPTIONS Structure and
Fixstrings, but no time in the moment to test this all.
Or the Callback is required?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Yup, the callback was the problem!

Code: Select all


XIncludeFile "SQX_Include.pbi"

Define.l Error, hFileMaskList, hArchive
Define.SQX_EXTRACTOPTIONS decompressOptions

Procedure SqxCallback(pParam.l,*pCallbackInfo.SQX_CALLBACKINFO)

 ProcedureReturn 1

EndProcedure

     Error = SqxInitArchive("myfile.sqx", 0, 0, @hArchive.l) 
     If Not Error
      hFileMaskList = SqxInitArcFileList(hArchive) 
      SqxAppendFileList(hArchive.l, hFileMaskList.l, "*.*")

      decompressOptions\cbSize = SizeOf(SQX_EXTRACTOPTIONS)
      decompressOptions.SQX_EXTRACTOPTIONS
      decompressOptions\cbSize = SizeOf(SQX_EXTRACTOPTIONS)
      decompressOptions\szOutputPath = "C:\"
      decompressOptions\fCreateFolders = #True 
      
      SqxExtractFiles(hArchive, @SqxCallback(), 0, hFileMaskList, @decompressOptions)
      If Not Error
        SqxDoneArcFileList(hArchive, hFileMaskList)
      Else
        Debug error
      EndIf 
     EndIf
Last edited by Inf0Byt3 on Tue Feb 27, 2007 10:08 pm, edited 1 time in total.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

empty callback :lol:

I thank you

greetings
Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Hehe yeah... I do that all the time :lol: . Thanks for the help and for the wrapper :D!
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

It seems that the callback has to return 1 afterall or it does not work
SQX_CALLBACK_FILENAME
SQX_CALLBACK_PROGRESS SQX_PROGRESS_CANCEL 0 The current operation will be cancelled.
SQX_PROGRESS_OK 1 Going on with the current operation.
Correction made to the post.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Post Reply