| Backend | Read | Write | Status |
|---|---|---|---|
| Local Filesystem | ✅ | ✅ | Full support |
| ZIP Archives | ✅ | ❌ | Read-only |
| TAR/TAR.GZ/TGZ | ✅ | ❌ | Read-only |
| 7Z Archives | ✅ | ❌ | Read-only |
| SFTP | ✅ | ✅ | Full support via ssh2 |
pub trait Vfs: Send + Sync {
fn instance_id(&self) -> &str;
fn metadata(&self, path: &Path) -> Result<FileMetadata, VfsError>;
fn read_dir(&self, path: &Path) -> Result<Vec<FileEntry>, VfsError>;
fn open_file(&self, path: &Path) -> Result<Box<dyn Read + Send>, VfsError>;
fn remove_file(&self, path: &Path) -> Result<(), VfsError>;
fn copy_file(&self, src: &Path, dest: &Path) -> Result<(), VfsError>;
fn exists(&self, path: &Path) -> bool;
}Enable write operations for existing archive formats.
Crate: Continue using zip crate (supports write)
Implementation Steps:
- Add
create_file()method to VFS trait - Add
remove_file()implementation for ZIP - Implement atomic write (write to temp, then replace)
- Handle compression level options
New VFS Trait Methods:
/// Creates a new file and returns a Write trait object
fn create_file(&self, path: &Path) -> Result<Box<dyn Write + Send>, VfsError>;
/// Creates a directory
fn create_dir(&self, path: &Path) -> Result<(), VfsError>;
/// Renames/moves a file or directory
fn rename(&self, from: &Path, to: &Path) -> Result<(), VfsError>;Files to Modify:
rcompare_common/src/vfs.rs- Add write methods to traitrcompare_core/src/vfs/archive.rs- Implement ZIP writercompare_core/src/vfs/local.rs- Implement new methods
Crate: Continue using tar crate (supports write)
Implementation Steps:
- Create
TarWriterstruct for building archives - Handle compression (gzip via
flate2) - Preserve file permissions and timestamps
- Implement streaming write for large files
Challenges:
- TAR archives are typically written sequentially
- May need to rebuild entire archive for modifications
- Consider "append mode" for adding files
Crate: sevenz-rust has limited write support
Implementation Steps:
- Evaluate
sevenz-rustwrite capabilities - If insufficient, consider
lzma-rsfor LZMA compression - May need to shell out to
7zbinary as fallback
Alternative: Use compress-tools crate which wraps libarchive
Crate: unrar (wrapper around unrar library)
Implementation Steps:
- Add
unrardependency - Create
RarVfsstruct implementingVfstrait - Handle password-protected archives
- Map RAR-specific errors to
VfsError
Code Structure:
// rcompare_core/src/vfs/rar.rs
pub struct RarVfs {
archive_path: PathBuf,
password: Option<String>,
entries: Vec<RarEntry>,
}
impl Vfs for RarVfs {
// Read-only implementation
}Cargo.toml Addition:
[dependencies]
unrar = "0.5"Crate: cdfs or iso9660
Use Cases:
- Compare ISO images
- Extract files from disk images
Implementation Steps:
- Add ISO parsing crate
- Create
IsoVfsstruct - Handle Rock Ridge and Joliet extensions
Support comparing compressed single files:
.gz(gzip).bz2(bzip2).xz(LZMA).zst(Zstandard)
Crates:
flate2(gzip)bzip2xz2orliblzmazstd
Implementation:
pub struct CompressedFileVfs {
inner_path: PathBuf,
compression: CompressionType,
}
pub enum CompressionType {
Gzip,
Bzip2,
Xz,
Zstd,
}Create virtual folder from search/filter results.
Use Cases:
- Compare only files matching a pattern
- Create filtered view of large directories
- Save search results as comparison source
Implementation:
pub struct FilteredVfs {
inner: Box<dyn Vfs>,
filter: FilterPredicate,
cached_entries: Vec<FileEntry>,
}
pub enum FilterPredicate {
Glob(String),
Regex(regex::Regex),
Size { min: Option<u64>, max: Option<u64> },
Modified { after: Option<SystemTime>, before: Option<SystemTime> },
Combined(Vec<FilterPredicate>),
}Combine multiple VFS sources into one virtual view.
Use Cases:
- Compare merged directory trees
- Overlay patches on base directories
- View multiple archives as one
Implementation:
pub struct UnionVfs {
layers: Vec<Box<dyn Vfs>>,
mode: UnionMode,
}
pub enum UnionMode {
/// First layer wins on conflict
FirstWins,
/// Last layer wins on conflict
LastWins,
/// Show all as separate entries
ShowAll,
}Create point-in-time snapshot for comparison.
Use Cases:
- Compare current state vs. saved snapshot
- Track changes over time
- Undo/rollback support
Implementation:
pub struct SnapshotVfs {
snapshot_path: PathBuf, // Serialized FileEntry list
metadata_cache: HashMap<PathBuf, FileMetadata>,
}Crate: webdav-client or reqwest with WebDAV protocol
Use Cases:
- Nextcloud/ownCloud servers
- Corporate file shares
- Online storage services
Crate: aws-sdk-s3 or rusoto_s3
Use Cases:
- AWS S3 buckets
- MinIO servers
- Backblaze B2
- Google Cloud Storage (S3-compatible mode)
Implementation Considerations:
- Pagination for large buckets
- Parallel listing with prefixes
- Caching for performance
- Credential management
Complexity: HIGH (OAuth, API rate limits)
Recommendation: Defer to dedicated sync tools or use FUSE mounts
Crate: git2 (libgit2 bindings)
Features:
- Compare branches/commits
- View file at specific revision
- Browse history
Implementation:
pub struct GitVfs {
repo: git2::Repository,
reference: GitRef,
}
pub enum GitRef {
Head,
Branch(String),
Commit(git2::Oid),
Tag(String),
}Complexity: HIGH (SVN protocol, authentication)
Recommendation: Lower priority, Git dominates modern VCS usage
| Feature | Impact | Effort | Priority | Target |
|---|---|---|---|---|
| ZIP Write | High | Medium | P1 | v1.1 |
| TAR Write | High | Medium | P1 | v1.1 |
| RAR Read | Medium | Low | P2 | v1.2 |
| 7Z Write | Medium | High | P3 | v1.2 |
| ISO Read | Low | Medium | P3 | v1.2 |
| Compressed Files | Medium | Low | P2 | v1.2 |
| Search Results VFS | High | Medium | P2 | v1.3 |
| Union VFS | Medium | Medium | P3 | v1.3 |
| Snapshot VFS | Medium | Medium | P3 | v1.3 |
| WebDAV | Low | High | P4 | v2.0 |
| S3 | Low | High | P4 | v2.0 |
| Git VFS | Medium | Very High | P5 | v2.x |
For full write support, extend the trait:
pub trait VfsWrite: Vfs {
/// Check if VFS supports write operations
fn is_writable(&self) -> bool;
/// Create a new file
fn create_file(&self, path: &Path) -> Result<Box<dyn Write + Send>, VfsError>;
/// Create a directory
fn create_dir(&self, path: &Path) -> Result<(), VfsError>;
/// Create directory and all parents
fn create_dir_all(&self, path: &Path) -> Result<(), VfsError>;
/// Rename/move a file or directory
fn rename(&self, from: &Path, to: &Path) -> Result<(), VfsError>;
/// Set file modification time
fn set_mtime(&self, path: &Path, mtime: SystemTime) -> Result<(), VfsError>;
/// Flush any pending writes
fn flush(&self) -> Result<(), VfsError>;
}For archive writes, implement transactional semantics:
pub trait VfsTransaction: VfsWrite {
/// Begin a transaction
fn begin(&self) -> Result<TransactionId, VfsError>;
/// Commit changes
fn commit(&self, tx: TransactionId) -> Result<(), VfsError>;
/// Rollback changes
fn rollback(&self, tx: TransactionId) -> Result<(), VfsError>;
}For network VFS backends, consider async interface:
#[async_trait]
pub trait AsyncVfs: Send + Sync {
async fn metadata(&self, path: &Path) -> Result<FileMetadata, VfsError>;
async fn read_dir(&self, path: &Path) -> Result<Vec<FileEntry>, VfsError>;
async fn open_file(&self, path: &Path) -> Result<AsyncRead, VfsError>;
}Each VFS backend needs:
- Basic read operations
- Directory listing
- Error handling
- Edge cases (empty files, deep paths, special characters)
- Cross-VFS copy operations
- Archive round-trip (create, modify, verify)
- Large file handling
- Concurrent access
Create test archives for each format:
tests/fixtures/
├── test.zip
├── test.tar.gz
├── test.7z
├── test.rar
└── test.iso
zip- ZIP archivestar- TAR archivesflate2- gzip compressionsevenz-rust- 7Z archivesssh2- SFTP
unrar- RAR archives (read-only)cdfsoriso9660- ISO imagesbzip2- bzip2 compressionxz2- LZMA compressionzstd- Zstandard compression
aws-sdk-s3- S3 storagereqwest- HTTP/WebDAVgit2- Git repositories
- Extend VFS trait with write methods
- Implement ZIP write support
- Implement TAR write support
- Add sync operations for archives
- GUI integration for archive modifications
- RAR read support
- ISO read support
- Compressed file support (.gz, .bz2, .xz, .zst)
- 7Z write support (if feasible)
- Search Results VFS
- Union/Overlay VFS
- Snapshot VFS
- GUI integration for virtual folders
- WebDAV support
- S3-compatible storage
- Improved caching and offline support
This roadmap prioritizes features that provide the most value with reasonable implementation effort. Archive write support (Phase 1) is the highest priority as it enables bidirectional sync operations with archives. Additional archive formats (Phase 2) expand compatibility. Virtual folders (Phase 3) provide advanced filtering and comparison capabilities. Cloud/network support (Phase 4+) is lower priority due to complexity and the availability of alternative tools (rclone, FUSE mounts).