From 5ef1f70a3ae6139602d27f96fa8179ec18d291b3 Mon Sep 17 00:00:00 2001 From: cabelo Date: Mon, 25 Mar 2019 12:05:18 -0300 Subject: [PATCH] Redirect STDOUT to file --- README.md | 6 ++++++ src/main/cpp/tiv.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 4b2926a..d3394f2 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,9 @@ If multiple images match the filename spec, thumbnails are shown. The top image was generated with the character optimization disabled via the `-0` option. ![Comparison](https://i.imgur.com/OzdCeh6.png) + +## Redirect to file + +Bellow the example for redirect stdout to one file. + +![Redirect](https://i.imgur.com/8UyGjg8.png) diff --git a/src/main/cpp/tiv.cpp b/src/main/cpp/tiv.cpp index aeb1fc5..5476cf8 100644 --- a/src/main/cpp/tiv.cpp +++ b/src/main/cpp/tiv.cpp @@ -442,6 +442,11 @@ cimg_library::CImg load_rgb_CImg(const char * const filename) { int main(int argc, char* argv[]) { struct winsize w; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + + //If redirect STDOUT to one file ( col and row == 0 ) + if(w.ws_col == 0 && w.ws_row == 0) { + ioctl(0, TIOCGWINSZ, &w); + } int maxWidth = w.ws_col * 4; int maxHeight = w.ws_row * 8;