Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

1.9 KB
Raw Blame
//! rf-core: platform-independent model for rustyfiles (entries, sorting, filtering, navigation).

pub mod addrcmd;
pub mod entry;
pub mod format;
pub mod history;
pub mod hotkey;
pub mod namefilter;
pub mod navtree;
pub mod openrules;
pub mod organize;
pub mod previewpane;
pub mod recycle_bin;
pub mod propcols;
pub mod rename;
pub mod shelf;
pub mod sort;
pub mod sortkeys;
pub mod thumbcache;
pub mod tags;
pub mod touched;
pub mod transfer;
pub mod treemap;

pub use entry::{Entry, EntryKind, attrs};
pub use history::{History, Location};
pub use sort::{SortDir, SortKey, SortSpec};

/// Renames an unreadable settings/data file to `<name>.bozuk-<unix secs>` so a later save
/// cannot silently destroy what the user had (they can fix and restore it). Best effort.
pub fn backup_corrupt(path: &std::path::Path) {
    let ms = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_millis()).unwrap_or(0);
    let mut name = path.file_name().map(|n| n.to_os_string()).unwrap_or_default();
    name.push(format!(".bozuk-{ms}"));
    let _ = std::fs::rename(path, path.with_file_name(name));
}

/// Reads a small config file, retrying briefly on transient errors (antivirus / sync tools
/// holding it open) so a passing lock is not mistaken for a broken file.
pub fn read_config(path: &std::path::Path) -> std::io::Result<String> {
    let mut last = None;
    for attempt in 0..3 {
        match std::fs::read_to_string(path) {
            Ok(t) => return Ok(t),
            Err(e) if e.kind() == std::io::ErrorKind::NotFound || e.kind() == std::io::ErrorKind::InvalidData => return Err(e),
            Err(e) => {
                last = Some(e);
                if attempt < 2 {
                    std::thread::sleep(std::time::Duration::from_millis(80));
                }
            }
        }
    }
    Err(last.unwrap_or_else(|| std::io::Error::other("read failed")))
}
pub mod desktop;
pub mod textload;
pub mod wintags;