Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Unified Diff: test/file-stream.h

Issue 427014: Fix a test tool for OTS, ot-sanitise.... (Closed) Base URL: http://ots.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ots.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/file-stream.h
===================================================================
--- test/file-stream.h (revision 10)
+++ test/file-stream.h (working copy)
@@ -9,29 +9,39 @@
namespace ots {
+// An OTSStream implementation for testing.
class FILEStream : public OTSStream {
public:
explicit FILEStream(FILE *stream)
- : file_(stream) {
+ : file_(stream), position_(0) {
}
~FILEStream() {
}
bool WriteRaw(const void *data, size_t length) {
- return fwrite(data, length, 1, file_) == 1;
+ if (::fwrite(data, length, 1, file_) == 1) {
Evan Martin 2009/11/23 17:44:19 Does this function succeed when writing to /dev/nu
Yusuke Sato 2009/11/23 17:59:24 Yes, at least on Linux 2.6.
+ position_ += length;
+ return true;
+ }
+ return false;
}
bool Seek(off_t position) {
- return fseek(file_, position, SEEK_SET) == 0;
+ if (!::fseeko(file_, position, SEEK_SET)) {
+ position_ = position;
+ return true;
+ }
+ return false;
}
off_t Tell() const {
- return ftell(file_);
+ return position_;
}
private:
FILE * const file_;
+ off_t position_;
};
} // namespace ots
« no previous file with comments | « src/ots.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698