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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef OTS_FILE_STREAM_H_
6 #define OTS_FILE_STREAM_H_
7
8 #include "opentype-sanitiser.h"
9
10 namespace ots {
11
12 // An OTSStream implementation for testing.
13 class FILEStream : public OTSStream {
14 public:
15 explicit FILEStream(FILE *stream)
16 : file_(stream), position_(0) {
17 }
18
19 ~FILEStream() {
20 if (file_)
21 fclose(file_);
22 }
23
24 bool WriteRaw(const void *data, size_t length) {
25 if (!file_ || ::fwrite(data, length, 1, file_) == 1) {
26 position_ += length;
27 return true;
28 }
29 return false;
30 }
31
32 bool Seek(off_t position) {
33 #if defined(_WIN32)
34 if (!file_ || !::_fseeki64(file_, position, SEEK_SET)) {
35 position_ = position;
36 return true;
37 }
38 #else
39 if (!file_ || !::fseeko(file_, position, SEEK_SET)) {
40 position_ = position;
41 return true;
42 }
43 #endif // defined(_WIN32)
44 return false;
45 }
46
47 off_t Tell() const {
48 return position_;
49 }
50
51 private:
52 FILE * const file_;
53 off_t position_;
54 };
55
56 } // namespace ots
57
58 #endif // OTS_FILE_STREAM_H_
OLDNEW
« 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