aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System
diff options
context:
space:
mode:
authorJeff Cohen <jeffc@jolt-lang.org>2005-01-01 22:54:05 +0000
committerJeff Cohen <jeffc@jolt-lang.org>2005-01-01 22:54:05 +0000
commitc6dffe0a5b84504ee5529e8d0c0a3c83694197bb (patch)
treeb07fb2286fbfd9bb8b47066b6f0df7b8795435d9 /lib/System
parentb63cfccd20a560086d8eae6a217d85914582a4b6 (diff)
downloadexternal_llvm-c6dffe0a5b84504ee5529e8d0c0a3c83694197bb.zip
external_llvm-c6dffe0a5b84504ee5529e8d0c0a3c83694197bb.tar.gz
external_llvm-c6dffe0a5b84504ee5529e8d0c0a3c83694197bb.tar.bz2
Add functions for determining if the stdin/out/err is connected to a
console or not. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19236 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r--lib/System/Win32/Process.cpp13
-rw-r--r--lib/System/Win32/Process.inc13
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/System/Win32/Process.cpp b/lib/System/Win32/Process.cpp
index 10fec05..dc46641 100644
--- a/lib/System/Win32/Process.cpp
+++ b/lib/System/Win32/Process.cpp
@@ -14,6 +14,7 @@
#include "Win32.h"
#include <psapi.h>
#include <malloc.h>
+#include <io.h>
#pragma comment(lib, "psapi.lib")
@@ -99,5 +100,17 @@ void Process::PreventCoreFiles() {
// dialog box from coming up. Or maybe not...
}
+bool Process::StandardInIsUserInput() {
+ return GetFileType((HANDLE)_get_osfhandle(0)) == FILE_TYPE_CHAR;
+}
+
+bool Process::StandardOutIsDisplayed() {
+ return GetFileType((HANDLE)_get_osfhandle(1)) == FILE_TYPE_CHAR;
+}
+
+bool Process::StandardErrIsDisplayed() {
+ return GetFileType((HANDLE)_get_osfhandle(2)) == FILE_TYPE_CHAR;
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
diff --git a/lib/System/Win32/Process.inc b/lib/System/Win32/Process.inc
index 10fec05..dc46641 100644
--- a/lib/System/Win32/Process.inc
+++ b/lib/System/Win32/Process.inc
@@ -14,6 +14,7 @@
#include "Win32.h"
#include <psapi.h>
#include <malloc.h>
+#include <io.h>
#pragma comment(lib, "psapi.lib")
@@ -99,5 +100,17 @@ void Process::PreventCoreFiles() {
// dialog box from coming up. Or maybe not...
}
+bool Process::StandardInIsUserInput() {
+ return GetFileType((HANDLE)_get_osfhandle(0)) == FILE_TYPE_CHAR;
+}
+
+bool Process::StandardOutIsDisplayed() {
+ return GetFileType((HANDLE)_get_osfhandle(1)) == FILE_TYPE_CHAR;
+}
+
+bool Process::StandardErrIsDisplayed() {
+ return GetFileType((HANDLE)_get_osfhandle(2)) == FILE_TYPE_CHAR;
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab