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
13
src/util.cpp
13
src/util.cpp
@ -379,9 +379,16 @@ void Util::setFilePermissions(const boost::filesystem::path& path, const boost::
|
||||
|
||||
int Util::getTerminalWidth()
|
||||
{
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
return static_cast<int>(w.ws_col);
|
||||
int width;
|
||||
if(isatty(STDOUT_FILENO))
|
||||
{
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
width = static_cast<int>(w.ws_col);
|
||||
}
|
||||
else
|
||||
width = 10000;//Something sufficiently big
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user