aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-26 03:33:13 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-26 03:33:13 +0000
commit5984680c1fe7ad98381154c26f9c009e4c91b08c (patch)
treedfa90135469f3e70d5f69b832423d0d0c941f373 /lib/Support
parent896617b776e7b015346160645b19be776cbe3805 (diff)
downloadexternal_llvm-5984680c1fe7ad98381154c26f9c009e4c91b08c.zip
external_llvm-5984680c1fe7ad98381154c26f9c009e4c91b08c.tar.gz
external_llvm-5984680c1fe7ad98381154c26f9c009e4c91b08c.tar.bz2
Add 'tell' method to raw_fd_ostream that clients can use to query the current location in the file the stream is writing to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60085 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/raw_ostream.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index a8e6c78..b10677e 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -253,6 +253,14 @@ void raw_fd_ostream::close() {
FD = -1;
}
+uint64_t raw_fd_ostream::tell() {
+ // We have to take into account the bytes waiting in the buffer. For now
+ // we do the easy thing and just flush the buffer before getting the
+ // current file offset.
+ flush();
+ return (uint64_t) lseek(FD, 0, SEEK_CUR);
+}
+
//===----------------------------------------------------------------------===//
// raw_stdout/err_ostream
//===----------------------------------------------------------------------===//