diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h --- a/llvm/include/llvm/Support/FileSystem.h +++ b/llvm/include/llvm/Support/FileSystem.h @@ -634,6 +634,12 @@ /// platform-specific error_code. std::error_code is_other(const Twine &path, bool &result); +/// Does FD refer to a terminal? +/// +/// @param FD Input file descriptor. +/// @returns true if the file descriptor refers to a terminal. +bool is_tty(int FD); + /// Get file status as if by POSIX stat(). /// /// @param path Input path. diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -694,6 +694,10 @@ return fillStatus(StatRet, Status, Result); } +bool is_tty(int FD) { + return isatty(FD); +} + std::error_code setPermissions(const Twine &Path, perms Permissions) { SmallString<128> PathStorage; StringRef P = Path.toNullTerminatedStringRef(PathStorage); diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/lib/Support/Windows/Path.inc @@ -734,6 +734,10 @@ return getStatus(FileHandle, Result); } +bool is_tty(int FD) { + return _isatty(FD); +} + std::error_code setPermissions(const Twine &Path, perms Permissions) { SmallVector PathUTF16; if (std::error_code EC = widenPath(Path, PathUTF16))