diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vtcol.rs | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs index 31ea9d9..e9af6e2 100644 --- a/src/vtcol.rs +++ b/src/vtcol.rs @@ -526,29 +526,18 @@ fn fd_of_path(path: &std::path::Path) -> Option<Fd> } } -fn get_console_fd(path: Option<&str>) -> Option<Fd> +fn get_console_fd() -> Option<Fd> { - match path { - Some(path) => { - let path = std::path::Path::new(path); - match fd_of_path(path) { - Some(fd) => Some(fd), - None => panic!("cannot open {:?} as a tty", path), - } - }, - None => { - for path in CONSOLE_PATHS.iter() { - vrb!("trying path: {:?}", path); - let path = std::path::Path::new(path); - if let Some(fd) = fd_of_path(path) { - vrb!(" * Success!"); - return Some(fd); - } - } - vrb!("could not retrieve fd for any of the search paths"); - None - }, + for path in CONSOLE_PATHS.iter() { + vrb!("trying path: {:?}", path); + let path = std::path::Path::new(path); + if let Some(fd) = fd_of_path(path) { + vrb!(" * Success!"); + return Some(fd); + } } + vrb!("could not retrieve fd for any of the search paths"); + None } fn write_to_term(fd: Fd, buf: &str) @@ -579,7 +568,7 @@ fn main() }; vrb!("Using palette:"); vrb!("{}", pal); - let fd = get_console_fd(None).unwrap(); + let fd = get_console_fd().unwrap(); vrb!("fd: {}", fd); if unsafe { ioctl(fd, PIO_CMAP, std::mem::transmute(&mut pal)) } < 0 { |