Skip to content

Adds recursive directory mode#112

Merged
hellobertrand merged 6 commits intomainfrom
feat/cli-multiples
Feb 27, 2026
Merged

Adds recursive directory mode#112
hellobertrand merged 6 commits intomainfrom
feat/cli-multiples

Conversation

@hellobertrand
Copy link
Owner

Implements a new --recursive (-r) command-line option, enabling the tool to process entire directory structures for compression or decompression.

  • Recursive Processing: Allows zxc to traverse specified directories and all their subdirectories, processing regular files encountered.
  • Implicit Multiple Mode: The recursive option automatically activates the multiple files mode, simplifying handling of numerous files.
  • Cross-Platform Directory Handling: Incorporates platform-specific logic for robust directory traversal on both Windows and POSIX systems.
  • Prevents Redundant Compression: Automatically skips already compressed .xc files when performing recursive compression.
  • Code Modularity: Refactors the core single-file processing logic into a dedicated function for improved maintainability.
  • Documentation & Tests: Updates the man page with usage examples for recursive mode and adds new command-line interface tests to verify functionality.

Introduces the `-m` or `--multiple` option, enabling `zxc` to process several input files in a single command. Each file is handled independently, with output filenames automatically derived from the input (e.g., `file.txt` compresses to `file.txt.xc`, `file.txt.xc` decompresses to `file.txt`).

When `-m` is active, output to standard output (`-c`) is explicitly disallowed to prevent ambiguous stream concatenation.

Refactors the CLI's file handling to iterate over multiple input files provided on the command line. Updates argument parsing to correctly distinguish between a single input/output pair and a list of multiple input files.

Adds dedicated CLI tests to cover compression, decompression, and the stdout restriction for multiple file operations.
Introduces the `--recursive` (`-r`) CLI option, enabling the processing of all regular files within specified directories and their subdirectories.

The feature implicitly enables `--multiple` mode, ensuring consistency with existing multi-file processing logic.

Includes OS-specific implementations for directory handling (Windows and POSIX) and comprehensive test cases.
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Marks the `dirent` pointer returned by `readdir` as `const`.
Ensures that directory entry data is treated as read-only within the processing loop, improving type safety and adhering to `readdir`'s expected usage.
Improves code clarity and robustness by marking variables that are not reassigned after initialization as constant.
Exposes new CLI options for batch processing in the help message.
Users can now specify multiple input files with `--multiple` and
process directories recursively with `--recursive`, enhancing the CLI's
ability to handle a wider range of operations.
Elevates the scope of the resolved output path and introduces a flag to track if an output file was created. If an operation fails, any created output file is now automatically unlinked, preventing the accumulation of incomplete files.

Adds checks for successful memory allocation before using buffers for I/O functions like `setvbuf`, improving robustness against `malloc` failures.
@hellobertrand hellobertrand merged commit f881ab6 into main Feb 27, 2026
44 checks passed
@hellobertrand hellobertrand deleted the feat/cli-multiples branch February 27, 2026 20:11
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.

1 participant