pub fn destroy() {
    p!("This overwrites the file with junk several times.");
    p!("The file is then deleted and the program exits.");

    if ask_bool("Destroy the file?", true) {
        p!("Destroying...");

        let path = get_file_path();

        for i in 1..=10 {
            match fs::write(&path, gibberish(10_000)) {
                Ok(_) => {
                    if i < 10 {
                        // Maybe there's not a good reason for this
                        // But the idea is to let the file system assimilate the write
                        // In case there's some debouncer system in place
                        thread::sleep(time::Duration::from_millis(500));
                    }
                }
                Err(_) => {
                    e!("Can't overwrite file.");
                    break;
                }
            }
        }

        match fs::remove_file(&path) {
            Ok(_) => exit(),
            Err(_) => show_message("< Can't Destroy File >"),
        }
    }
}
// Writes gibberish to the file several times
// Then deletes the file
// Then exists the program
Writes gibberish to the file several times
Then deletes the file
Then exists the program
Writes gibberish to the file several times Then deletes the file Then exists the program
pub fn destroy() {
    p!("This overwrites the file with junk several times.");
    p!("The file is then deleted and the program exits.");
    if ask_bool("Destroy the file?", true) {
        p!("Destroying...");
        let path = get_file_path();
        for i in 1..=10 {
            match fs::write(&path, gibberish(10_000)) {
                Ok(_) => {
                    if i < 10 {
                        // Maybe there's not a good reason for this
                        // But the idea is to let the file system assimilate the write
                        // In case there's some debouncer system in place
                        thread::sleep(time::Duration::from_millis(500));
                    }
                }
                Err(_) => {
                    e!("Can't overwrite file.");
                    break;
                }
            }
        }
        match fs::remove_file(&path) {
            Ok(_) => exit(),
            Err(_) => show_message("< Can't Destroy File >"),
        }
    }
}
pub fn destroy ( ) { p ! ( " " ) ; p ! ( " " ) ; if ask_bool ( " " , true ) { p ! ( " " ) ; let path = get_file_path ( ) ; for i in 1 ..= 10 { match fs :: write ( & path , gibberish ( 10_000 ) ) { Ok ( _ ) => { if i < 10 { // Maybe there's not a good reason for this // But the idea is to let the file system assimilate the write // In case there's some debouncer system in place thread :: sleep ( time :: Duration :: from_millis ( 500 ) ) ; } } Err ( _ ) => { e ! ( " " ) ; break ; } } } match fs :: remove_file ( & path ) { Ok ( _ ) => exit ( ) , Err ( _ ) => show_message ( " " ) , } } }
Writes gibberish to the file several times
Then deletes the file
Then exists the program
Writes gibberish to the file several times Then deletes the file Then exists the program