A collection of high-performance CLI tools written in Rust for common shell operations.
A fast, multi-threaded tool for checking the integrity of ZIP archives and detecting password-protected files.
- π Multi-threaded processing - Automatically uses all available CPU cores for maximum performance
- β Integrity validation - Verifies ZIP archive structure and file accessibility
- π Password detection - Identifies encrypted/password-protected archives
- π Recursive scanning - Automatically scans directories for ZIP files
- π― Clear output - Color-coded visual indicators for different file states
- π Optional logging - Save validation results to a timestamped log file
- π§ Deadlock-free - Carefully designed concurrent architecture for reliability
git clone https://github.com/huangcheng/shell-utils.git
cd shell-utils
cargo build --releaseThe binary will be available at target/release/check-zip.
cargo install --path czCheck ZIP files in the current directory:
check-zipCheck ZIP files in a specific directory:
check-zip --path /path/to/directory
# or
check-zip -p /path/to/directorySave results to a log file:
# Save to default timestamped log file in current directory
check-zip --log .
# Save to specific log file
check-zip --log results.log
# Save to specific directory (creates timestamped file)
check-zip --log /path/to/logs/
# Combine options
check-zip -p /data/archives -l validation.logThe tool provides clear color-coded visual feedback for each ZIP file:
π Recursively checking all ZIP files in current directory (/path/to/dir)...
β
[VALID] documents.zip
π [PASSWORD PROTECTED] encrypted.zip
β [CORRUPTED] broken.zip - Invalid zip format: unexpected EOF
β
[VALID] backup.zip
========================================================
π Validation Complete - Summary Statistics:
Total files checked: 4
β
Intact files: 2
β Corrupted files: 1
βοΈ Skipped files (password protected or unsupported): 1
π Log file saved successfully at: check-zip_20260107123456789.log
- β [VALID] - ZIP archive is valid and accessible
- π [PASSWORD PROTECTED] - ZIP archive contains encrypted files
- β [CORRUPTED] - ZIP archive is damaged or unreadable (includes error details)
- βοΈ [UNSUPPORTED] - ZIP format is not supported (reserved for future use)
The tool automatically detects and uses all available CPU cores for parallel processing, making it extremely fast for scanning large directories with many ZIP files.
Key Performance Features:
- Concurrent file walking - Discovers files in parallel with validation
- Worker thread pool - Distributes validation across all CPU cores
- Deadlock-free architecture - Carefully designed lock ordering prevents blocking
- Efficient resource usage - Releases locks before I/O operations for maximum throughput
Benchmark Example:
- 1,000 ZIP files on 8-core system: ~10 seconds (vs. ~80 seconds sequential)
- Scales linearly with CPU core count
Usage: check-zip [OPTIONS]
Options:
-p, --path <FOLDER> Folder to operate on [default: current directory]
-l, --log <LOG_FILE> Log file or directory to write results to
-h, --help Print help
-V, --version Print version
- Rust 1.70 or higher (2024 edition)
Build all tools:
cargo build --releaseBuild a specific tool:
cargo build --release -p czcargo testcargo run -p cz -- --path /path/to/directoryshell-utils/
βββ cz/ # check-zip tool
β βββ src/
β β βββ main.rs # Main application logic with concurrent processing
β β βββ cli.rs # CLI argument parsing
β βββ Cargo.toml
βββ Cargo.toml # Workspace configuration
βββ README.md
βββ CODE_REVIEW_SUMMARY.md # Detailed code review and concurrency analysis
The application uses a multi-threaded architecture with the following components:
- Walker Thread - Recursively scans directories and collects ZIP file paths
- Worker Thread Pool - Processes ZIP files in parallel using all available CPU cores
- Shared State - Uses
Arc<Mutex<T>>for thread-safe access to:- Path queue for work distribution
- Result counters for statistics
- Log entries for output collection
The code has been carefully reviewed and optimized to prevent deadlocks:
- β Locks are released before I/O operations
- β Consistent lock acquisition ordering
- β Minimal lock holding time
- β No nested lock acquisition
See CODE_REVIEW_SUMMARY.md for detailed concurrency analysis.
The tool detects password-protected archives through two methods:
- Checking the
encrypted()flag on individual files - Catching "Password required to decrypt file" errors during validation
This dual approach ensures reliable detection across different ZIP formats and encryption methods.
Solution: Ensure you have read permissions for the directories and files being scanned. On Unix systems:
chmod +r /path/to/files/*.zipSolution: The tool may hit OS limits with very large directories. Increase the limit:
# macOS/Linux
ulimit -n 4096Solution: For best performance, scan local files. Network I/O can significantly slow down parallel operations.
Solution: This is a cosmetic issue when multiple threads print simultaneously. Use the log file option (-l) for
clean, ordered output.
Q: How many files can it handle?
A: The tool has been tested with directories containing 10,000+ ZIP files. Memory usage scales linearly with the number
of files.
Q: Does it extract or modify archives?
A: No, the tool only reads archives for validation. It never modifies files.
Q: Can it detect partial corruption?
A: Yes, it validates the entire ZIP structure and attempts to read metadata from all contained files.
Q: What about nested ZIP files?
A: Currently, only top-level ZIP files are validated. Nested archives are not recursively checked.
Q: Does it work on Windows?
A: Yes, the tool is cross-platform and works on Windows, macOS, and Linux.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Add progress bar with
indicatiffor better user feedback - Add JSON/CSV output format for automated processing
- Implement retry logic for transient I/O errors
- Add verbose mode with detailed per-file diagnostics
- Support for .zipx and other ZIP variants
- Add support for other archive formats (tar.gz, 7z, rar)
- Implement archive repair functionality for corrupted files
- Add hash verification for archive contents
- Parallel extraction/verification of archive contents
- Add filter options (by size, date, pattern)
- GUI version with real-time progress visualization
- Integration with cloud storage services
- Add more shell utilities to the collection
- Plugin system for custom validation rules
HUANG Cheng
- clap (4.5+) - Command-line argument parsing with derive macros
- zip (2.2+) - ZIP archive reading and validation
- chrono (0.4+) - Timestamp generation for log files
- colour (2.1+) - Color-coded console output