summaryrefslogtreecommitdiffstats
path: root/llvm/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
commite076257b8cfe4c34e62d13d2b3c342509fb830b5 (patch)
tree1771b9eb30f7ce5525d5f05b35127ce013cb72de /llvm/lib/Support
parent6d71b7fb95688b72f40674bc05945810c64ab623 (diff)
downloadbcm5719-llvm-e076257b8cfe4c34e62d13d2b3c342509fb830b5.tar.gz
bcm5719-llvm-e076257b8cfe4c34e62d13d2b3c342509fb830b5.zip
Add 'tell' method to raw_fd_ostream that clients can use to query the current location in the file the stream is writing to.
llvm-svn: 60085
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index a8e6c782bc9..b10677e3f27 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/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
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud