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

Unified Diff: third_party/ots/test/file-stream.h

Issue 775893002: Updating OTS repo from https://github.com/khaledhosny/ots.git (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating with 4800 warning fix Created 6 years 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 | « third_party/ots/test/cff_type2_charstring_test.cc ('k') | third_party/ots/test/idempotent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/ots/test/file-stream.h
diff --git a/third_party/ots/test/file-stream.h b/third_party/ots/test/file-stream.h
new file mode 100644
index 0000000000000000000000000000000000000000..44dd4a1e0fb89d40f0d40bdd4090f7a6b7974884
--- /dev/null
+++ b/third_party/ots/test/file-stream.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_FILE_STREAM_H_
+#define OTS_FILE_STREAM_H_
+
+#include "opentype-sanitiser.h"
+
+namespace ots {
+
+// An OTSStream implementation for testing.
+class FILEStream : public OTSStream {
+ public:
+ explicit FILEStream(FILE *stream)
+ : file_(stream), position_(0) {
+ }
+
+ ~FILEStream() {
+ if (file_)
+ fclose(file_);
+ }
+
+ bool WriteRaw(const void *data, size_t length) {
+ if (!file_ || ::fwrite(data, length, 1, file_) == 1) {
+ position_ += length;
+ return true;
+ }
+ return false;
+ }
+
+ bool Seek(off_t position) {
+#if defined(_WIN32)
+ if (!file_ || !::_fseeki64(file_, position, SEEK_SET)) {
+ position_ = position;
+ return true;
+ }
+#else
+ if (!file_ || !::fseeko(file_, position, SEEK_SET)) {
+ position_ = position;
+ return true;
+ }
+#endif // defined(_WIN32)
+ return false;
+ }
+
+ off_t Tell() const {
+ return position_;
+ }
+
+ private:
+ FILE * const file_;
+ off_t position_;
+};
+
+} // namespace ots
+
+#endif // OTS_FILE_STREAM_H_
« no previous file with comments | « third_party/ots/test/cff_type2_charstring_test.cc ('k') | third_party/ots/test/idempotent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698