- Extract mover and undo functionality into dedicated modules (mover/ and undo/ subdirectories) - Move cross-platform file operations to separate file_ops.rs module for reusability - Extract batch and categorizer tests into separate test files (batch_test.rs, categorizer_test.rs) - Refactor orchestrator.rs with extracted helper functions for improved readability - Separate cache and undo log initialization - Extract path resolution and offline mode determination logic - Simplify main organization flow by delegating to helper functions - Update module exports to expose new types and functions (MoveError, MoveSummary, UndoError, UndoSummary) - Reduce code duplication of move_file_cross_platform implementation
17 lines
459 B
Rust
17 lines
459 B
Rust
use std::{fs, io, path::Path};
|
|
|
|
pub fn move_file_cross_platform(source: &Path, target: &Path) -> io::Result<()> {
|
|
match fs::rename(source, target) {
|
|
Ok(()) => Ok(()),
|
|
Err(e) => {
|
|
if cfg!(windows) || e.kind() == io::ErrorKind::CrossesDevices {
|
|
fs::copy(source, target)?;
|
|
fs::remove_file(source)?;
|
|
Ok(())
|
|
} else {
|
|
Err(e)
|
|
}
|
|
}
|
|
}
|
|
}
|