OSDN Git Service

Fix SupportsSeeking detection on windows.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 13 Apr 2015 11:09:48 +0000 (11:09 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 13 Apr 2015 11:09:48 +0000 (11:09 +0000)
Will be tested by existing tests once used (soon).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234737 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/raw_ostream.cpp

index b8588af..16c52c9 100644 (file)
@@ -525,7 +525,14 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered)
 
   // Get the starting position.
   off_t loc = ::lseek(FD, 0, SEEK_CUR);
+#ifdef LLVM_ON_WIN32
+  // MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for pipes.
+  sys::fs::file_status Status;
+  std::error_code EC = status(FD, Status);
+  SupportsSeeking = !EC && Status.type() == sys::fs::file_type::regular_file;
+#else
   SupportsSeeking = loc != (off_t)-1;
+#endif
   if (!SupportsSeeking)
     pos = 0;
   else