Skip to content

Conversation

@wizzomafizzo
Copy link
Member

Summary

  • Add support for identifying games inside ZIP, 7z, and RAR archives
  • Support MiSTer-style paths (e.g., /path/to/archive.zip/folder/game.gba)
  • Auto-detect game file when given just an archive path

New archive Package

  • archive.go: Core Archive interface and factory function
  • zip.go: ZIP implementation (stdlib archive/zip)
  • sevenzip.go: 7z implementation (bodgit/sevenzip)
  • rar.go: RAR implementation (nwaples/rardecode/v2)
  • path.go: MiSTer-style path parsing
  • detect.go: Game file detection by extension
  • errors.go: Custom error types

Features

  • Explicit paths: /games/roms.zip/gba/game.gba
  • Auto-detect: /games/roms.zip finds first game file by extension
  • Cartridge-only: GB, GBC, GBA, NES, SNES, N64, Genesis
  • Disc images in archives return DiscNotSupportedError

Dependencies

  • github.com/bodgit/sevenzip (BSD-3-Clause)
  • github.com/nwaples/rardecode/v2 (BSD-2-Clause)

Test plan

  • Unit tests for archive package (path parsing, file listing, reading)
  • Integration tests for all 3 formats (ZIP, 7z, RAR)
  • Tests for SNES and Genesis ROMs in archives
  • Tests for MiSTer-style explicit paths
  • make check passes

Add support for identifying games inside ZIP, 7z, and RAR archives
using MiSTer-style paths (e.g., /path/to/archive.zip/folder/game.gba)
and auto-detection when given just an archive path.

New archive package:
- archive.go: Core Archive interface and factory function
- zip.go: ZIP implementation using stdlib archive/zip
- sevenzip.go: 7z implementation using bodgit/sevenzip
- rar.go: RAR implementation using nwaples/rardecode/v2
- path.go: MiSTer-style path parsing
- detect.go: Game file detection by extension
- errors.go: Error types (FormatError, FileNotFoundError, etc.)

Features:
- Explicit internal paths: /games/roms.zip/gba/game.gba
- Auto-detect game file: /games/roms.zip (finds first game by extension)
- Supports cartridge-based games only (GB, GBC, GBA, NES, SNES, N64, Genesis)
- Disc-based games in archives return DiscNotSupportedError

Dependencies added:
- github.com/bodgit/sevenzip (BSD-3-Clause)
- github.com/nwaples/rardecode/v2 (BSD-2-Clause)
@codecov
Copy link

codecov bot commented Dec 10, 2025

Add comprehensive tests to improve patch coverage:
- TestSevenZipAndRAR_Operations: Consolidated table-driven tests for 7z and RAR
  archive operations (List, Open, OpenReaderAt, case-insensitive matching)
- TestDetectConsoleFromExtension: Full coverage for extension-based console
  detection including ambiguous extensions, .gz suffix handling, and edge cases
- TestIdentifyFromArchive_*: Tests for archive identification including direct
  calls, disc console errors, unsupported consoles, and non-existent files
- TestDetectConsoleFromCue_*: Tests for CUE sheet console detection including
  Saturn and SegaCD magic headers, empty CUE files, and missing BIN files
- TestByteReaderAt edge cases: Fixed errorlint issues using errors.Is()

Coverage improvements:
- DetectConsoleFromExtension: 44.4% -> 100%
- detectConsoleFromCue: 0% -> 69.6%
- IdentifyFromArchive: 0% -> 88.2%
- archive/sevenzip.go: 0% -> covered
- archive/rar.go: 0% -> covered
@wizzomafizzo wizzomafizzo merged commit 3e25eba into main Dec 10, 2025
9 checks passed
@wizzomafizzo wizzomafizzo deleted the feature/archive-support branch December 10, 2025 08:48
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