teamy-mft 0.7.1

TeamDman's Master File Table CLI and library for NTFS.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::windows_utils::console::attach_ctrl_c_handler;
use crate::windows_utils::console::console_detach;
use crate::windows_utils::console::is_inheriting_console;

pub fn hide_default_console_or_attach_ctrl_handler() -> eyre::Result<()> {
    if is_inheriting_console() {
        // There is an existing console (e.g., VSCode), so attach ctrl+c handler for graceful shutdowns
        attach_ctrl_c_handler()?;
    } else {
        // No existing console (e.g., double-clicked exe), so detach from the default console window
        // No need for ctrl+c handler since there is no console to send ctrl+c to
        _ = console_detach();
    };

    Ok(())
}