Logo
Explore Help
Register Sign In
siddheshmhatre/noentropy
1
0
Fork 0
You've already forked noentropy
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity
Files
10e508fa0e18953f5e61dfcf2251c8e32c86c5e3
noentropy/src/files/file_ops.rs

17 lines
459 B
Rust
Raw Normal View History

refactor: reorganize file operations and extract test modules - 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
2026-01-10 21:08:00 +05:30
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)
}
}
}
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.3 Page: 89ms Template: 6ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API