Skip to content

feat(archive): add comprehensive ZIP and RAR creation and extraction with password and split volumes - #8

Merged
HanzoDev30 merged 4 commits into
HanzoDev30:mainfrom
Afton-programmer:feat/archive-manager
Oct 22, 2026
Merged

HanzoDev30 merged 4 commits into
HanzoDev30:mainfrom
Afton-programmer:feat/archive-manager

Conversation

@Afton-programmer

@Afton-programmer Afton-programmer commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

📦 Complete Technical Breakdown (0 to 100): Implementation of Full Archive Creation & Extraction (ZIP, RAR, 7Z, TAR, Password Support & Multi-Part Volumes)

📌 Summary

This update introduces complete, desktop-grade archive management to Ghostide (comparable to WinRAR and 7-Zip). Users can now create password-protected and multi-part/split ZIP archives from any folder or selection of files, as well as extract ZIP, RAR (including multi-volume .part1.rar / .r00), 7Z, and TAR archives with automatic password prompting and real-time progress feedback.


🔍 1. Architecture & Design Breakdown

A. Archive Creation (ZipUtil.java & dialog_create_zip.xml)

  • Triggers:
    1. Folder 3-Dot Menu: Clicking the three dots (ivMore) on any directory row in FileManagerActivity now displays "Create ZIP file" (create_zip_title).
    2. Multi-Selection Mode: Selecting multiple files and/or folders and tapping the "Zip" option in the bottom action bar.
  • Features in the Creation Dialog:
    • Archive Name: Pre-filled with <item_name>.zip or custom name.
    • Password Protection: AES-256 standard encryption via Zip4j (AesKeyStrength.KEY_STRENGTH_256).
    • Compression Levels: Fastest, Normal, and Maximum.
    • Split / Multi-Part Volumes: Switch to enable volume splitting with preset partitions:
      • 10 MB
      • 50 MB
      • 100 MB
      • 700 MB (CD)
      • 2 GB
      • 4 GB (DVD / FAT32)
      • Custom partition size (MB)
  • Engine Execution:
    • Uses Zip4j's native createSplitZipFileFromFolder / createSplitZipFile / addFolder / addFile run asynchronously on an ExecutorService.
    • Polled via Zip4j's ProgressMonitor (monitor.getWorkCompleted(), monitor.getTotalWork(), monitor.getPercentDone(), monitor.getFileName()), providing smooth, accurate real-time UI progress.

B. Universal Extraction Engine (ArchiveExtractUtil.java)

  • Supported Formats:
    • ZIP / Split ZIP: Single .zip and split multi-volume zip files (.z01, .z02, ... .zip). Handled via Zip4j.
    • RAR / Multi-Part RAR: Single .rar, modern multi-volume (.part1.rar, .part2.rar), and legacy multi-volume (.r00, .r01). Handled via com.github.junrar:junrar:7.5.5.
    • 7-Zip (.7z): Single and password-protected 7z archives via Apache Commons Compress (SevenZFile).
    • TAR / Compressed TAR: .tar, .tar.gz, .tgz, .tar.bz2, .tbz2, .tar.xz, .txz via TarArchiveInputStream combined with GZIPInputStream, BZip2CompressorInputStream, and XZCompressorInputStream.
  • Smart Multi-Volume Resolution (resolveFirstVolume):
    • If a user selects any non-first partition (e.g. archive.part2.rar or archive.z01), the engine scans the directory for the primary header volume (archive.part1.rar or archive.zip) and starts extraction from there.
  • Dynamic Password Prompting (promptPasswordSync):
    • When an encrypted archive is encountered and no password was provided:
      1. The background extraction thread pauses using CountDownLatch.
      2. A Material 3 dialog (dialog_archive_password.xml) is rendered on the UI thread asking the user for the password.
      3. Once the user submits or cancels, the latch releases: if submitted, extraction continues with the decryption key; if cancelled, the worker cleanly aborts.
  • Path Traversal Protection (Security):
    • Every extracted entry is checked: if (sanitizedName.contains("..")) continue; to prevent directory traversal / zip-slip vulnerabilities.

C. User Interface Integration (FileManagerActivity.java)

  • Item Click Handler:
    • Tapping a .zip file shows an action dialog: "Browse Archive" (internal zip explorer) or "Extract Archive".
    • Tapping a .rar, .7z, or other archive directly launches the extraction destination dialog.
  • Item 3-Dot Menu:
    • For folders: Added "Create ZIP file".
    • For archives: Added "Extract Here", "Extract to /", and "Browse Archive" (for ZIP).
  • M3 Styling:
    • All dialogs adhere strictly to Material 3 design and M3Theme.java specifications, without hardcoded color values.
    • Localization is complete with full English and Persian (values-fa) string sets.

📊 2. Verification on CI (GitHub Actions)

  • Branch: feat/archive-manager
  • Commits:
    • aca04f2: feat(archive): add comprehensive ZIP and RAR creation and extraction with password and split volumes
    • 62848a9: fix(archive): use correct Archive constructors and cancelAllTasks on ProgressMonitor
  • PR: HanzoDev30/Ghostide #8
  • Workflow Run Results:
    • Run ID 39833745425:
      • build-plugin-sdk: SUCCESS (58s)
      • build (assembleDebug): SUCCESS (2m 1s) -> Generated app-debug.apk and ghostide-plugin-sdk.aar.
    • Run ID 39833745432:
      • build: SUCCESS (2m 31s).

- Disable continuous per-frame dynamic background in ExpandableLayout
- Share RecycledViewPool across all setting section RecyclerViews
- Cache and avoid redundant background drawable allocations in PreferenceSwitchGroup
- Eliminate quadratic DiffUtil and post() queue spam in SettingsAdapter
- Cache preference accesses in ShapeUtil
- Debounce search queries to 200ms
@Afton-programmer

Copy link
Copy Markdown
Contributor Author

📦 Complete Technical Breakdown (0 to 100): Implementation of Full Archive Creation & Extraction (ZIP, RAR, 7Z, TAR, Password Support & Multi-Part Volumes)

📌 Summary

This update introduces complete, desktop-grade archive management to Ghostide (comparable to WinRAR and 7-Zip). Users can now create password-protected and multi-part/split ZIP archives from any folder or selection of files, as well as extract ZIP, RAR (including multi-volume .part1.rar / .r00), 7Z, and TAR archives with automatic password prompting and real-time progress feedback.


🔍 1. Architecture & Design Breakdown

A. Archive Creation (ZipUtil.java & dialog_create_zip.xml)

  • Triggers:
    1. Folder 3-Dot Menu: Clicking the three dots (ivMore) on any directory row in FileManagerActivity now displays "Create ZIP file" (create_zip_title).
    2. Multi-Selection Mode: Selecting multiple files and/or folders and tapping the "Zip" option in the bottom action bar.
  • Features in the Creation Dialog:
    • Archive Name: Pre-filled with <item_name>.zip or custom name.
    • Password Protection: AES-256 standard encryption via Zip4j (AesKeyStrength.KEY_STRENGTH_256).
    • Compression Levels: Fastest, Normal, and Maximum.
    • Split / Multi-Part Volumes: Switch to enable volume splitting with preset partitions:
      • 10 MB
      • 50 MB
      • 100 MB
      • 700 MB (CD)
      • 2 GB
      • 4 GB (DVD / FAT32)
      • Custom partition size (MB)
  • Engine Execution:
    • Uses Zip4j's native createSplitZipFileFromFolder / createSplitZipFile / addFolder / addFile run asynchronously on an ExecutorService.
    • Polled via Zip4j's ProgressMonitor (monitor.getWorkCompleted(), monitor.getTotalWork(), monitor.getPercentDone(), monitor.getFileName()), providing smooth, accurate real-time UI progress.

B. Universal Extraction Engine (ArchiveExtractUtil.java)

  • Supported Formats:
    • ZIP / Split ZIP: Single .zip and split multi-volume zip files (.z01, .z02, ... .zip). Handled via Zip4j.
    • RAR / Multi-Part RAR: Single .rar, modern multi-volume (.part1.rar, .part2.rar), and legacy multi-volume (.r00, .r01). Handled via com.github.junrar:junrar:7.5.5.
    • 7-Zip (.7z): Single and password-protected 7z archives via Apache Commons Compress (SevenZFile).
    • TAR / Compressed TAR: .tar, .tar.gz, .tgz, .tar.bz2, .tbz2, .tar.xz, .txz via TarArchiveInputStream combined with GZIPInputStream, BZip2CompressorInputStream, and XZCompressorInputStream.
  • Smart Multi-Volume Resolution (resolveFirstVolume):
    • If a user selects any non-first partition (e.g. archive.part2.rar or archive.z01), the engine scans the directory for the primary header volume (archive.part1.rar or archive.zip) and starts extraction from there.
  • Dynamic Password Prompting (promptPasswordSync):
    • When an encrypted archive is encountered and no password was provided:
      1. The background extraction thread pauses using CountDownLatch.
      2. A Material 3 dialog (dialog_archive_password.xml) is rendered on the UI thread asking the user for the password.
      3. Once the user submits or cancels, the latch releases: if submitted, extraction continues with the decryption key; if cancelled, the worker cleanly aborts.
  • Path Traversal Protection (Security):
    • Every extracted entry is checked: if (sanitizedName.contains("..")) continue; to prevent directory traversal / zip-slip vulnerabilities.

C. User Interface Integration (FileManagerActivity.java)

  • Item Click Handler:
    • Tapping a .zip file shows an action dialog: "Browse Archive" (internal zip explorer) or "Extract Archive".
    • Tapping a .rar, .7z, or other archive directly launches the extraction destination dialog.
  • Item 3-Dot Menu:
    • For folders: Added "Create ZIP file".
    • For archives: Added "Extract Here", "Extract to /", and "Browse Archive" (for ZIP).
  • M3 Styling:
    • All dialogs adhere strictly to Material 3 design and M3Theme.java specifications, without hardcoded color values.
    • Localization is complete with full English and Persian (values-fa) string sets.

📊 2. Verification on CI (GitHub Actions)

  • Branch: feat/archive-manager
  • Commits:
    • aca04f2: feat(archive): add comprehensive ZIP and RAR creation and extraction with password and split volumes
    • 62848a9: fix(archive): use correct Archive constructors and cancelAllTasks on ProgressMonitor
  • PR: HanzoDev30/Ghostide #8
  • Workflow Run Results:
    • Run ID 39833745425:
      • build-plugin-sdk: SUCCESS (58s)
      • build (assembleDebug): SUCCESS (2m 1s) -> Generated app-debug.apk and ghostide-plugin-sdk.aar.
    • Run ID 39833745432:
      • build: SUCCESS (2m 31s).

@HanzoDev30

Copy link
Copy Markdown
Owner

@Afton-programmer using M3Theme.java for add new Layout res

@HanzoDev30
HanzoDev30 merged commit c9b0900 into HanzoDev30:main Oct 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants