RCompare is a high-performance file and directory comparison tool written in Rust. It provides both command-line and graphical interfaces for comparing folders, detecting differences, and identifying orphaned files.
# Clone the repository
git clone https://github.com/aecs4u/rcompare
cd rcompare
# Build release binaries
cargo build --release
# Binaries will be in target/release/
# - rcompare_cli (4.6 MB)
# - rcompare_gui (21 MB)# Install CLI
cargo install --path rcompare_cli
# Install GUI
cargo install --path rcompare_guiCompare two directories:
rcompare_cli scan /path/to/left /path/to/right================================================================================
Comparison Results
================================================================================
== file1.txt (Identical)
!= file2.txt (Different content)
<< file3.txt (Left only)
>> file4.txt (Right only)
================================================================================
Summary:
Total files: 4
Identical: 1 (==)
Different: 1 (!=)
Left only: 1 (<<)
Right only: 1 (>>)
================================================================================
# Ignore specific patterns
rcompare_cli scan /left /right -i "*.o" -i "*.tmp" -i "node_modules/"
# Show only differences (hide identical files)
rcompare_cli scan /left /right --diff-only
# Enable hash verification for same-sized files
rcompare_cli scan /left /right --verify-hashes
# Use custom cache directory
rcompare_cli scan /left /right --cache-dir /path/to/cache
# Follow symbolic links
rcompare_cli scan /left /right -LRCompare provides two graphical interfaces:
- Slint GUI (rcompare_gui): Native, lightweight, cross-platform
- PySide6 GUI (Python frontend): Feature-rich with advanced diff viewers
rcompare_gui- Select Directories: Click "Select Left..." and "Select Right..." to choose directories
- Compare: Click the "Compare" button to run the comparison
- View Results: Files are displayed side-by-side with color coding:
- 🟢 Green background: Identical files
- 🔴 Red background: Different files
- 🟡 Yellow background: Left only
- 🔵 Blue background: Right only
- Status Bar: Shows summary statistics at the bottom
- Refresh: Click "Refresh" to re-run the comparison
The PySide6 frontend provides advanced features including specialized diff viewers for text, images, CSV, Excel, JSON, and binary files.
# Install Python dependencies
pip install PySide6 Pillow openpyxl
# Or use requirements file (if available)
pip install -r frontend/requirements.txt# From the repository root
python frontend/main.py
# Or if installed as a package
teczka- Directory Comparison: Full directory tree comparison with expand/collapse
- Specialized Diff Viewers:
- Text Diff: Line-by-line comparison with syntax highlighting
- Image Diff: Side-by-side image comparison with pixel differences
- CSV Diff: Row/column comparison for CSV files
- Excel Diff: Sheet and cell-level comparison
- JSON/YAML Diff: Structural comparison with formatting
- Binary Diff: Hex viewer for binary files
- File Operations: Copy left/right with progress tracking
- Export: JSON output for automation and scripting
- Settings: Configurable comparison options and display preferences
RCompare provides a C-compatible Foreign Function Interface (FFI) for integrating patch parsing and manipulation into C/C++ applications. This is particularly useful for KDE applications and other C++ projects that need libkomparediff2-compatible functionality.
# Build the static library
cargo build --package rcompare_ffi --release
# Library location:
# Linux/macOS: target/release/librcompare_ffi.a
# Windows: target/release/rcompare_ffi.lib
# Header file:
# rcompare_ffi/include/rcompare.h#include "rcompare.h"
#include <stdio.h>
#include <string.h>
int main(void) {
const char* diff_text =
"--- a/file.txt\n"
"+++ b/file.txt\n"
"@@ -1 +1 @@\n"
"-old\n"
"+new\n";
// Parse diff
PatchSetHandle* handle = NULL;
int result = rcompare_parse_diff(
(const uint8_t*)diff_text,
strlen(diff_text),
&handle
);
if (result != 0) {
fprintf(stderr, "Parse failed\n");
return 1;
}
// Access metadata
size_t file_count = rcompare_patchset_file_count(handle);
printf("Files: %zu\n", file_count);
// Cleanup
rcompare_free_patchset(handle);
return 0;
}# Add RCompare FFI to your project
add_subdirectory(path/to/rcompare/rcompare_ffi)
# Link to your target
target_link_libraries(your_target PRIVATE rcompare)- Parse multiple diff formats: Unified, context, normal, RCS, ed
- Auto-detect generators: CVS, Perforce, Subversion, plain diff
- Patch operations: Apply/unapply individual or all differences
- File blending: Merge original file content with patch hunks
- Serialization: Convert patch model back to unified diff format
- Memory safe: Opaque handle pattern with proper lifetime management
For complete API reference and examples, see:
- rcompare_ffi/README.md
- rcompare_ffi/include/rcompare.h
- C examples:
rcompare_ffi/examples/
==: Files are identical (same size, timestamp, and content)!=: Files differ in content<<: File exists only on the left side (orphan)>>: File exists only on the right side (orphan)??: Files have same size but not verified (use --verify-hashes)
- Light Green: Identical files
- Light Red: Different files
- Light Yellow: Left-only files
- Light Blue: Right-only files
- Gray: Unchecked files
RCompare automatically caches file hashes to avoid re-computing them:
- Linux:
~/.cache/rcompare/ - Windows:
%LOCALAPPDATA%\rcompare\cache\ - macOS:
~/Library/Caches/rcompare/
The cache stores:
- File path
- Modification time
- File size
- BLAKE3 hash
Files are only re-hashed if their size or modification time changes.
For best performance with large directories:
- Use ignore patterns to exclude unnecessary directories
- Let the hash cache build up over time
- The scanner uses parallel traversal automatically
RCompare keeps file metadata in memory during comparison. For very large directories (1M+ files), expect memory usage of approximately:
- Typical: 100-200 bytes per file
- Example: 1 million files ≈ 100-200 MB RAM
# Compare backup with source
rcompare_cli scan /source /backup --verify-hashes# Check local vs remote code, ignoring build artifacts
rcompare_cli scan /local/project /remote/project \
-i "*.o" -i "*.so" -i "target/" -i "node_modules/"# Ensure deployed files match build artifacts
rcompare_cli scan /build/output /var/www/html --diff-only# Find duplicate directory structures
rcompare_cli scan /downloads/set1 /downloads/set2# Set custom cache directory
export RCOMPARE_CACHE_DIR=/path/to/cache
# Enable debug logging
export RUST_LOG=debug
rcompare_cli scan /left /rightCreate a .rcompare.ignore file (future feature):
# Ignore build artifacts
*.o
*.so
*.dll
target/
build/
# Ignore dependencies
node_modules/
vendor/
# Ignore temporary files
*.tmp
*.swp
.DS_Store
Run with appropriate permissions or use sudo for system directories.
Clear the cache manually:
# Linux/macOS
rm -rf ~/.cache/rcompare/
# Windows
rmdir /s %LOCALAPPDATA%\rcompare\cache\Ensure you have the required graphics libraries:
# Linux (Ubuntu/Debian)
sudo apt install libfontconfig1-dev libxcb-shape0-dev libxcb-xfixes0-dev
# Fedora
sudo dnf install fontconfig-devel libxcb-devel- Check if you're comparing network drives (slower I/O)
- Use ignore patterns to exclude unnecessary directories
- Disable hash verification if not needed
- Use SSD instead of HDD for cache directory
Ctrl+L: Select left directoryCtrl+R: Select right directoryCtrl+Enter: Run comparisonF5: RefreshCtrl+Q: Quit
rcompare_cli scan <LEFT> <RIGHT> [OPTIONS]
OPTIONS:
-i, --ignore <PATTERN> Ignore patterns (can be repeated)
-L, --follow-symlinks Follow symbolic links
-v, --verify-hashes Verify file hashes for same-sized files
-c, --cache-dir <DIR> Cache directory for hash storage
-d, --diff-only Show only differences (hide identical files)
-h, --help Print help
-V, --version Print versionThe CLI uses diff-aware exit codes for automation and scripting:
- 0: No differences found (directories are identical)
- 1: Error occurred (invalid arguments, I/O error, etc.)
- 2: Differences found between directories
Example usage in scripts:
#!/bin/bash
rcompare_cli scan /source /backup --verify-hashes
case $? in
0)
echo "✓ Backup is up to date"
;;
2)
echo "⚠ Backup has differences"
exit 1
;;
*)
echo "✗ Comparison failed"
exit 1
;;
esacUse --json for machine-readable output. The JSON schema is versioned for compatibility:
rcompare_cli scan /left /right --json > results.jsonJSON Schema (version 1.1.0):
{
"schema_version": "1.1.0",
"left": "/path/to/left",
"right": "/path/to/right",
"summary": {
"total": 100,
"same": 80,
"different": 10,
"orphan_left": 5,
"orphan_right": 5,
"unchecked": 0
},
"entries": [
{
"path": "file.txt",
"status": "Different",
"left": {
"size": 1024,
"modified_unix": 1706633400,
"is_dir": false
},
"right": {
"size": 2048,
"modified_unix": 1706633500,
"is_dir": false
}
}
],
"text_diffs": [...],
"image_diffs": [...],
"csv_diffs": [...]
}Schema Versions:
1.0.0: Basic comparison results1.1.0: Added specialized diff reports (current)
# Compare backup with source
rcompare_cli scan ~/Documents ~/Backup/Documents# Verify website deployment
rcompare_cli scan ./dist /var/www/html \
--diff-only \
--verify-hashes# Check if projects are in sync, ignore build artifacts
rcompare_cli scan \
~/dev/project \
/mnt/remote/project \
-i "target/" \
-i "*.o" \
-i ".git/" \
--diff-only# Find duplicate photos in different folders
rcompare_cli scan \
~/Photos/2023 \
~/Photos/Backup/2023 \
--verify-hashes- Documentation: See ARCHITECTURE.md for technical details
- Development Status: See DEVELOPMENT_STATUS.md
- Issues: Report bugs on GitHub
- CLI Help:
rcompare_cli --help
RCompare currently provides:
- ✅ BLAKE3 hashing with persistent cache
- ✅ Parallel directory traversal
- ✅ Gitignore pattern support
- ✅ Cross-platform support (Linux, Windows, macOS)
- ✅ Text diff viewer with syntax highlighting
- ✅ Archive comparison (ZIP, TAR, 7Z)
- ✅ Binary hex viewer
- ✅ Image comparison with pixel diff
- ✅ CSV and Excel comparison
- ✅ JSON and YAML structural diff
- ✅ Parquet DataFrame comparison
- ✅ Multi-format diff parser (unified, context, normal, RCS, ed)
- ✅ Patch apply/unapply operations
- ✅ File blending with original content
- ✅ C/C++ FFI layer (libkomparediff2-compatible)
- ✅ CLI with progress indicators and JSON output
- ✅ Native Slint GUI
- ✅ PySide6 GUI with specialized viewers
- ✅ Copy operations (left/right)
Future enhancements planned:
- 🚧 Parallel hash computing (2-3x speedup)
- 📋 Three-way merge
- 📋 Tabs for multiple comparisons
- 📋 Synced scrolling with diff map
- 📋 HTML/Markdown/CSV report export
- 📋 JUnit XML for CI integration
- 📋 Diff statistics dashboard
- 📋 Comparison presets (save/load)
- 📋 Additional cloud providers (GCS, Azure, Dropbox)
- 📋 Watch mode for continuous monitoring
- 📋 Semantic diff (AST-based)
- 📋 Plugin/extension system
See ROADMAP.md for detailed development timeline.
Version: 0.3.0-dev Last Updated: 2026-01-30 License: MIT OR Apache-2.0