Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v1.2.0 - Bug Fix Release: CLI Extract Directory Option

Choose a tag to compare

@zombocoder zombocoder released this 07 Sep 10:57
· 6 commits to main since this release
52fe28c

πŸ› Bug Fixes

Fixed -C Flag in Extract Command

  • Issue: The -C/--directory option in bfc extract command was failing with "I/O error" when using relative paths to container files
  • Root Cause: The CLI was changing to the output directory before opening the container file, breaking relative path resolution
  • Fix: Reordered operations to open the container file before changing directories
  • Impact: The -C flag now works correctly for extracting to specific directories

πŸ”§ Technical Details

Problem

# This was failing with "I/O error"
bfc extract -C /tmp/output ../path/to/container.bfc

The issue occurred because:

  1. CLI parsed -C /tmp/output option
  2. Code executed chdir("/tmp/output")
  3. Code tried to open ../path/to/container.bfc (now relative to /tmp/output)
  4. Container file not found, causing I/O error

Solution

  • File: src/cli/cmd_extract.c
  • Change: Moved container opening before directory change operation
  • Security: Maintains proper error handling and cleanup

Before (Broken)

// Change directory first (BROKEN)
if (opts.output_dir) {
    chdir(opts.output_dir);  // Changes working directory
}
bfc_open(opts.container_file, &reader);  // Relative path now broken

After (Fixed)

// Open container first (FIXED)
bfc_open(opts.container_file, &reader);  // Works with original relative path
if (opts.output_dir) {
    chdir(opts.output_dir);  // Safe to change directory after opening
}

βœ… Testing

Verified fix works with various scenarios:

  • Relative paths: bfc extract -C /tmp ../container.bfc βœ…
  • Absolute paths: bfc extract -C /tmp /full/path/container.bfc βœ…
  • Current directory: bfc extract -C /tmp container.bfc βœ…
  • All directory preservation options work: -k, -f, etc. βœ…

πŸ“‹ Usage

The -C flag now works as documented:

# Extract all files to /tmp directory
bfc extract -C /tmp archive.bfc

# Extract preserving directory structure to specific location
bfc extract -k -C /tmp/restored archive.bfc

# Extract with force overwrite to specific directory
bfc extract -f -C /tmp archive.bfc

πŸ”„ Backward Compatibility

  • No breaking changes: All existing functionality remains unchanged
  • API compatibility: Library API unchanged - this is purely a CLI fix
  • Container format: No changes to .bfc file format

πŸ“¦ What's Changed

  • Fixed CLI extract -C flag functionality in src/cli/cmd_extract.c
  • No changes to library code, container format, or other features
  • All tests pass, including new validation for the -C flag

This is a targeted bug fix release that resolves a specific issue with the CLI extraction functionality. Users who encountered the "I/O error" when using bfc extract -C should upgrade to this version.