[llvm-commits] [llvm] r60085 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp
Ted Kremenek
kremenek at apple.com
Tue Nov 25 19:33:13 PST 2008
Author: kremenek
Date: Tue Nov 25 21:33:13 2008
New Revision: 60085
URL: http://llvm.org/viewvc/llvm-project?rev=60085&view=rev
Log:
Add 'tell' method to raw_fd_ostream that clients can use to query the current location in the file the stream is writing to.
Modified:
llvm/trunk/include/llvm/Support/raw_ostream.h
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=60085&r1=60084&r2=60085&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Tue Nov 25 21:33:13 2008
@@ -175,7 +175,10 @@
virtual void flush_impl();
/// close - Manually flush the stream and close the file.
- void close();
+ void close();
+
+ /// tell - Return the current offset with the file.
+ uint64_t tell();
};
/// raw_stdout_ostream - This is a stream that always prints to stdout.
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=60085&r1=60084&r2=60085&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Tue Nov 25 21:33:13 2008
@@ -253,6 +253,14 @@
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
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list