mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Made getTerminalWidth detect if it is running in a terminal before trying to get the width.
This commit is contained in:
parent
d11f376030
commit
5822bce376
@ -378,10 +378,17 @@ void Util::setFilePermissions(const boost::filesystem::path& path, const boost::
|
||||
}
|
||||
|
||||
int Util::getTerminalWidth()
|
||||
{
|
||||
int width;
|
||||
if(isatty(STDOUT_FILENO))
|
||||
{
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
return static_cast<int>(w.ws_col);
|
||||
width = static_cast<int>(w.ws_col);
|
||||
}
|
||||
else
|
||||
width = 10000;//Something sufficiently big
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user