### Installer Configuration File Examples Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/sfx.htm Examples of configuration files for 7-Zip installers, which must be encoded in UTF-8 and wrapped with specific start and end markers. ```text ;!@Install@!UTF-8! Title="7-Zip 4.00" BeginPrompt="Do you want to install the 7-Zip 4.00?" RunProgram="setup.exe" ;!@InstallEnd@! ``` ```text ;!@Install@!UTF-8! Title="7-Zip 4.00" BeginPrompt="Do you want to install the 7-Zip 4.00?" ExecuteFile="7zip.msi" ;!@InstallEnd@! ``` ```text ;!@Install@!UTF-8! Title="7-Zip 4.01 Update" BeginPrompt="Do you want to install the 7-Zip 4.01 Update?" ExecuteFile="msiexec.exe" ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus" ;!@InstallEnd@! ``` -------------------------------- ### Install Project Documentation and License Files Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/CMakeLists.txt Installs various documentation and license files to the root of the installation directory. ```cmake INSTALL(FILES AUTHORS ChangeLog COPYING LGPL README ReleaseNotes.txt THANKS DESTINATION .) ``` -------------------------------- ### Run 7-Zip Benchmark Examples Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/commands/bench.htm Various command-line examples for executing the 7-Zip benchmark with different configurations. ```bash 7z b ``` ```bash 7z b -mmt1 -md26 ``` ```bash 7z b 30 ``` ```bash 7z b -mm=* ``` -------------------------------- ### Install JAR Files Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/CMakeLists.txt Installs the main JAR file and the library JAR file to the 'lib' directory of the installation. ```cmake INSTALL(FILES ${SEVENZIPJBINDING_JAR} ${SEVENZIPJBINDING_LIB_JAR} DESTINATION lib) ``` -------------------------------- ### Install 7zG Executable Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde3/readme.txt Steps to install the 7zG executable and its associated files on an Ubuntu system. This involves copying files and setting appropriate permissions. ```bash cp /usr/bin/7z /usr/bin/7zG ``` ```bash cp bin/7zG /usr/lib/p7zip/7zG ``` ```bash chmod 555 /usr/lib/p7zip/7zG ``` ```bash cp -r GUI/Lang /usr/lib/p7zip/Lang ``` ```bash find /usr/lib/p7zip/Lang -type d -exec chmod 555 {} \; ``` ```bash find /usr/lib/p7zip/Lang -type f -exec chmod 444 {} \; ``` ```bash cp -r GUI/help /usr/lib/p7zip/help ``` ```bash find /usr/lib/p7zip/help -type d -exec chmod 555 {} \; ``` ```bash find /usr/lib/p7zip/help -type f -exec chmod 444 {} \; ``` ```bash cp GUI/p7zipForFilemanager /usr/bin/p7zipForFilemanager ``` ```bash chmod 555 /usr/bin/p7zipForFilemanager ``` ```bash cp GUI/p7zip_16_ok.png /usr/share/icons/hicolor/16x16/apps/p7zip.png ``` ```bash chmod 444 /usr/share/icons/hicolor/16x16/apps/p7zip.png ``` -------------------------------- ### Wildcard Examples Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/syntax.htm Examples of 7-Zip wildcard matching patterns. ```text *.txt means all files with an extension of ".txt" ?a* means all files with a second character of "a" *1* means all names that contains character "1" *.*.* means all names that contain two at least "." characters ``` -------------------------------- ### Create Installer SFX Archive via Command Line Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/sfx.htm Concatenates an SFX module, an optional configuration file, and a 7z archive to create an installer executable. ```batch copy /b 7zS.sfx + config.txt + archive.7z archive.exe ``` -------------------------------- ### Install Library Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/CMakeLists.txt Configures the installation rules for the built library. It specifies the destination directories for the library, archive, and runtime files within the installation prefix. ```cmake install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} RUNTIME DESTINATION bin) ``` -------------------------------- ### Install KDE Context Menu Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde4/readme.txt Installs the context menu integration files for KDE environments (Dolphin or Konqueror). ```bash cp GUI/kde4/*.desktop /usr/share/kde4/services/ServiceMenus/ ``` -------------------------------- ### Silent Installation of 7-Zip (MSI Installer) Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/general/faq.htm Details the command-line parameters for a silent installation using the 7-Zip MSI package. The '/q' flag initiates a quiet installation, and INSTALLDIR specifies the target directory. ```bash msiexec /i 7z-x64.msi /q INSTALLDIR="C:\Program Files\7-Zip" ``` -------------------------------- ### Install KDE Dolphin Context Menu (All Users) Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde3/readme.txt Installs the 7zG context menu for Dolphin file manager for all users on the system. Requires root privileges. ```bash cp GUI/kde/*.desktop /usr/share/apps/d3lphin/servicemenus/ ``` -------------------------------- ### Start ssh-agent and add key Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/scripts/Windows/README.txt Use these commands to start the ssh-agent and add your private key for password-less authentication. Ensure ssh-agent is running and your key is added. ```bash eval `ssh-agent -s` ``` ```bash ssh-add ``` -------------------------------- ### Install CMakeLists.txt for Distribution Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/CMakeLists.txt Installs a specific CMakeLists.txt file, renaming it to CMakeLists.txt in the destination directory. ```cmake INSTALL(FILES CMakeFile-bin-dist.txt DESTINATION . RENAME CMakeLists.txt) ``` -------------------------------- ### Pre-packaging Temporary Directory Setup Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/CMakeLists.txt Sets up a temporary directory for pre-packaging operations and ensures it is clean before use. ```cmake SET(PREPACKAGE_TMP "${PROJECT_BINARY_DIR}/prepackage.tmp") SET(JAVADOC_DIR "${PREPACKAGE_TMP}/javadoc/") FILE(REMOVE_RECURSE ${PREPACKAGE_TMP}) FILE(MAKE_DIRECTORY ${PREPACKAGE_TMP}) ``` -------------------------------- ### Add Library and Install Rules Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/CMakeLists.txt Adds the project as a library and defines installation rules for the library files in the appropriate directories. ```cmake add_library(${PROJECT_NAME} ${SRC_LIST}) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} RUNTIME DESTINATION bin) ``` -------------------------------- ### Silent Installation of 7-Zip (EXE Installer) Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/general/faq.htm Provides the command-line parameters for performing a silent installation of the 7-Zip executable installer. The '/S' flag enables silent mode, and '/D=dir' specifies the installation directory. ```bash 7z-x64.exe /S /D=C:\Program Files\7-Zip ``` -------------------------------- ### 7zip -ai switch example Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/ar_include.htm This example demonstrates how to use the -ai switch with the 't' (Test) command to test *.7z archives in the current directory and all its subdirectories. ```bash 7z t -an -air!*.7z ``` -------------------------------- ### Install KDE Dolphin Context Menu (User) Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde3/readme.txt Installs the 7zG context menu for Dolphin file manager for the current user. Ensure the `~/.kde/share/apps/d3lphin/servicemenus/` directory exists. ```bash mkdir -p ~/.kde/share/apps/d3lphin/servicemenus/ ``` ```bash cp GUI/kde/*.desktop ~/.kde/share/apps/d3lphin/servicemenus/ ``` -------------------------------- ### Build and Test Commands Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/CPP/ANDROID/readme.txt Standard make commands for compiling, installing, cleaning, and testing the project. ```bash make all make install make clean cd 7za make test ``` -------------------------------- ### List File Content Example Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/syntax.htm Example content for a list file containing multiple file patterns. ```text My programs\*.cpp Src\*.cpp ``` -------------------------------- ### Install KDE Konqueror Context Menu (All Users) Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde3/readme.txt Installs the 7zG context menu for Konqueror file manager for all users on the system. Requires root privileges. ```bash cp GUI/kde/*.desktop /usr/share/apps/konqueror/servicemenus/ ``` -------------------------------- ### Build 7zG and Run Tests Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde3/readme.txt Use this command to build the 7zG executable and execute associated tests. Ensure you have the necessary build tools installed. ```bash make test_7zG ``` -------------------------------- ### Install Packaged Archives Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/CMakeLists.txt Installs the pre-packaged ZIP archives (Java source, C++ source, Javadoc, website) to the root of the installation directory. ```cmake INSTALL(FILES ${PREPACKAGE_TMP}/java-src.zip ${PREPACKAGE_TMP}/cpp-src.zip ${PREPACKAGE_TMP}/javadoc.zip ${PREPACKAGE_TMP}/website.zip DESTINATION .) ``` -------------------------------- ### Install KDE Konqueror Context Menu (User) Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde3/readme.txt Installs the 7zG context menu for Konqueror file manager for the current user. Ensure the `~/.kde/share/apps/konqueror/servicemenus/` directory exists. ```bash mkdir -p ~/.kde/share/apps/konqueror/servicemenus/ ``` ```bash cp GUI/kde/*.desktop ~/.kde/share/apps/konqueror/servicemenus/ ``` -------------------------------- ### Install 7z Shell Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/GUI/kde4/readme.txt Copies the 7z shell to be used for 7zG. Ensure you find the correct 7z installation path. ```bash cp /usr/bin/7z /usr/bin/7zG ``` -------------------------------- ### 7-Zip Update Command Example Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/update.htm Creates a new archive 'update.7z' containing files from the current directory that differ from 'exist.7z'. The original 'exist.7z' remains unchanged. This example utilizes specific update actions for different file states. ```bash 7z u c:\1\exist.7z -u- -up0q3x2z0!c:\1\update.7z *" ``` ```bash 7z u c:\1\exist.7z -up0q3x2z0!c:\1\update.7z * -ms=off ``` -------------------------------- ### Create archives with 7-Zip compression methods Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/method.htm Examples of using the 7z command-line tool to apply specific compression filters and methods to files. ```bash 7z a archive.zip *.jpg -mx0 ``` ```bash 7z a archive.7z *.exe *.dll -m0=BCJ -m1=LZMA:d=21 ``` ```bash 7z a archive.7z a.tar -mf=BCJ2 -mx ``` ```bash 7z a archive.7z *.wav -mf=Delta:4 ``` ```bash 7z a a.7z *.exe *.dll -m0=BCJ2 -m1=LZMA:d25 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 ``` ```bash 7z a archive.7z *.txt -m0=PPMd ``` ```bash 7z a a.tar.xz a.tar -mf=bcj -mx ``` -------------------------------- ### Execute Zip Archive Creation Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/doc/web.components/compression_snippets.html Command-line execution example for the Zip archive creation snippet. ```Bash $ java -cp ‹path-to-lib›\sevenzipjbinding.jar; \ ‹path-to-lib›\sevenzipjbinding-Windows-x86.jar;. \ CompressNonGenericZip compressed.zip ``` -------------------------------- ### Include Directories Setup Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/CMakeLists.txt Specifies the directories to be searched for include files during compilation. ```cmake include_directories( ${PROJECT_SOURCE_DIR}/../lzhamdecomp ${PROJECT_SOURCE_DIR}/../include) ``` -------------------------------- ### Zip Archive Creation Output Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/doc/web.components/compression_snippets.html Expected console output after running the Zip creation example. ```Text ##INCLUDE_OUTPUT(CompressNonGenericZip) ``` -------------------------------- ### Create Self-Extracting Archive with -sfx Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/sfx.htm Command-line examples for creating self-extracting archives using default or specific SFX modules. ```bash 7z a -sfx a.exe *.txt ``` ```bash 7z a -sfx7z.sfx a.exe * ``` -------------------------------- ### Manage NTFS Alternate Streams with 7-Zip Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/sns.htm Examples of using the -sns switch to add, extract, and list files with alternate data streams in WIM archives. ```bash 7z a a.wim -sns *.txt ``` ```bash 7z x a.wim ``` ```bash 7z x a.wim -sns- ``` ```bash 7z l a.wim -sns ``` -------------------------------- ### Exclude Archives with -ax Switch Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/ar_exclude.htm Use the -ax switch to exclude specific archives from an operation. This example tests all .7z archives except those starting with 'a'. ```bash 7z t -an -ai!*.7z -ax!a*.7z ``` -------------------------------- ### Exclude Specific Files with Wildcards Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/exclude.htm Use the -x switch with a wildcard to exclude files matching a pattern. This example adds all .txt files except those starting with 'temp.'. ```bash 7z a -tzip archive.zip *.txt -x!temp.* ``` -------------------------------- ### Run Initialization Check via Command Line Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/doc/web.components/first_steps.html Execute the initialization check program by including the core and native JARs in the classpath. ```bash $ java -cp ‹path-to-lib›/sevenzipjbinding.jar: \ ‹path-to-lib›/sevenzipjbinding-Linux-i686.jar:. \ SevenZipJBindingInitCheck ``` ```bash C:\Test> java -cp ‹path-to-lib›\sevenzipjbinding.jar; \ ‹path-to-lib›\sevenzipjbinding-Windows-x86.jar;. \ SevenZipJBindingInitCheck ``` -------------------------------- ### Configure SevenZip-JBinding Build Environment Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/CMakeLists.txt Initializes build directories, generates random build references, and sets up platform-specific property files. ```cmake GET_TARGET_PROPERTY(SEVENZIP_JBINDING_LIB 7-Zip-JBinding LOCATION) GET_FILENAME_COMPONENT(SEVENZIP_JBINDING_LIB_FILENAME "${SEVENZIP_JBINDING_LIB}" NAME) FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${PLATFORM}) STRING(RANDOM LENGTH 12 BUILD_REF) SET(SEVENZIPJBINDING_LIB_PROPERTY_FILE ${PROJECT_BINARY_DIR}/${PLATFORM}/sevenzipjbinding-lib.properties) SET(SEVENZIPJBINDING_PLATFORMS_PROPERTY_FILE sevenzipjbinding-platforms.properties) FILE(WRITE ${PROJECT_BINARY_DIR}/${SEVENZIPJBINDING_PLATFORMS_PROPERTY_FILE} "platform.1=${PLATFORM}\n") ``` -------------------------------- ### Create Zip Archive with Specific API Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/doc/web.components/compression_snippets.html Demonstrates creating a Zip archive by implementing IOutCreateCallback and using the IOutArchive interface. ```Java ##INCLUDE_SNIPPET(CompressNonGenericZip) ``` -------------------------------- ### Configure File Stream Callbacks Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/lzma.txt Set up file stream structures for input and output operations. ```C CFileSeqInStream inStream; CFileSeqOutStream outStream; inStream.funcTable.Read = MyRead; inStream.file = inFile; outStream.funcTable.Write = MyWrite; outStream.file = outFile; ``` -------------------------------- ### Create 7-Zip Archive with Specific API Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/doc/web.components/compression_snippets.html Demonstrates creating a 7z archive, noting that it requires less complex attribute calculation than Zip. ```Java ##INCLUDE_SNIPPET(CompressNonGeneric7z) ``` -------------------------------- ### Exclude archive type example Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/switches/stx.htm Extracts files from an archive while explicitly disabling the PE format handler. ```shell 7z x -stxpe archive.exe ``` -------------------------------- ### List Archive Items (Simple Interface) Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/doc/web.components/extraction_snippets.html Demonstrates how to list items within an archive using the simple interface. Note that 'folder' items and properties like packed size may not be supported by all archive formats or items, potentially returning null. ```java Archive archive = null; try { archive = new Archive(new File("test.zip")); for (ArchiveItem item : archive.getItems()) { System.out.println(item.getPath() + " " + item.getUnpackedSize() + " " + item.getPackedSize() + " " + item.getCRC() + " " + item.getMtime() + " " + item.isFolder()); } } catch (SevenZipException e) { e.printStackTrace(); } finally { if (archive != null) { try { archive.close(); } catch (SevenZipException e) { e.printStackTrace(); } } } ``` -------------------------------- ### FATAL Macros Should Be Exceptions Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/llm-wiki/entities/known-issues-todos.md Example of using FATAL macro for unrecoverable errors in C++. ```cpp // JavaStaticInfo.cpp:40 if (jni::OutOfMemoryError::_isInstance(env, exception)) { FATAL("Out of memory during method lookup: '%s', '%s'", _name, _signature); // TODO Change fatal => exception (+test) } ``` -------------------------------- ### Command Line Commands Reference Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/p7zip/DOC/MANUAL/cmdline/commands/index.htm A list of available commands for the SevenZipJBinding command line interface. ```APIDOC ## Command Line Commands ### Description The command is the first non-switch argument on the command line. Command names are not case sensitive. ### Available Commands - **a** - Add files to archive - **b** - Benchmark - **d** - Delete files from archive - **e** - Extract files from archive - **h** - Calculate hash - **i** - Show information about supported formats - **l** - List contents of archive - **rn** - Rename files in archive - **t** - Test archive integrity - **u** - Update files in archive - **x** - Extract files with full paths ``` -------------------------------- ### Get Number of Items in Archive Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/doc/web.components/index.html Retrieves the count of packed items within an archive. Error handling is omitted for brevity. ```java int numberOfItems = archive.getNumberOfItems(); ``` -------------------------------- ### Display Build Configuration Messages Source: https://github.com/borisbrodski/sevenzipjbinding/blob/master/CMakeLists.txt Outputs build environment details and instructions to the console. ```cmake MESSAGE("") MESSAGE("Build type: ${CMAKE_BUILD_TYPE}, platform: ${PLATFORM}") MESSAGE("") MESSAGE("Java VM: ${JAVA_RUNTIME}") MESSAGE("Java compiler: ${JAVA_COMPILE}") MESSAGE("Java header compiler: ${JAVA_HEADER_COMPILE}") MESSAGE("Java documentation tool: ${JAVA_DOC}") MESSAGE("Java archiver: ${JAVA_ARCHIVE}") MESSAGE("MinGW: ${MINGW}") MESSAGE("MinGW-32: ${MINGW32}") MESSAGE("MinGW-64: ${MINGW64}") MESSAGE("APPLE: ${APPLE}") IF(RUNTIME_LIB) MESSAGE("Runtime libaray to use: ${RUNTIME_LIB_FILENAME}") ENDIF() MESSAGE("Output package: ./${SEVENZIPJBINDING_FILENAME}.zip") MESSAGE("") MESSAGE("") MESSAGE("Type '${MAKE_COMMAND}' to compile") MESSAGE("Type 'ctest' to run tests (it could take up to 90 minutes on a slow CPU)") MESSAGE("Type '${MAKE_COMMAND} package' to build a distribution package") MESSAGE("") ```