1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-15 05:21:03 +01:00

treewide: Fix MinGW build

Several bugs to squash:

- Apparently DELETE is an already used macro with Win32. We can avoid it
  by using Camel case instead (slightly hacky but also fits the naming
  convention better)

- Gets rid of the raw usage of isatty. Added an isTTY impl to abstract over
  the raw API.
This commit is contained in:
Sergei Zimmerman 2025-11-18 04:30:57 +03:00
parent f8141a2c26
commit 8165419a0c
No known key found for this signature in database
10 changed files with 44 additions and 25 deletions

View file

@ -4,7 +4,15 @@
#include <limits>
#include <string>
#include "nix/util/file-descriptor.hh"
namespace nix {
/**
* Determine whether \param fd is a terminal.
*/
bool isTTY(Descriptor fd);
/**
* Determine whether ANSI escape sequences are appropriate for the
* present output.

View file

@ -64,6 +64,16 @@ inline std::pair<int, size_t> charWidthUTF8Helper(std::string_view s)
namespace nix {
bool isTTY(Descriptor fd)
{
#ifndef _WIN32
return isatty(fd);
#else
DWORD mode;
return GetConsoleMode(fd, &mode);
#endif
}
bool isTTY()
{
static const bool tty = isatty(STDERR_FILENO) && getEnv("TERM").value_or("dumb") != "dumb"