v1.2.0 - Bug Fix Release: CLI Extract Directory Option
π Bug Fixes
Fixed -C Flag in Extract Command
- Issue: The
-C/--directoryoption inbfc extractcommand 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
-Cflag 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.bfcThe issue occurred because:
- CLI parsed
-C /tmp/outputoption - Code executed
chdir("/tmp/output") - Code tried to open
../path/to/container.bfc(now relative to/tmp/output) - 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 brokenAfter (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
-Cflag functionality insrc/cli/cmd_extract.c - No changes to library code, container format, or other features
- All tests pass, including new validation for the
-Cflag
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.