Add missing export and import source files to password_manager's browser target.
[chromium-blink-merge.git] / third_party / ots / test / file-stream.h
blob44dd4a1e0fb89d40f0d40bdd4090f7a6b7974884
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.
5 #ifndef OTS_FILE_STREAM_H_
6 #define OTS_FILE_STREAM_H_
8 #include "opentype-sanitiser.h"
10 namespace ots {
12 // An OTSStream implementation for testing.
13 class FILEStream : public OTSStream {
14 public:
15 explicit FILEStream(FILE *stream)
16 : file_(stream), position_(0) {
19 ~FILEStream() {
20 if (file_)
21 fclose(file_);
24 bool WriteRaw(const void *data, size_t length) {
25 if (!file_ || ::fwrite(data, length, 1, file_) == 1) {
26 position_ += length;
27 return true;
29 return false;
32 bool Seek(off_t position) {
33 #if defined(_WIN32)
34 if (!file_ || !::_fseeki64(file_, position, SEEK_SET)) {
35 position_ = position;
36 return true;
38 #else
39 if (!file_ || !::fseeko(file_, position, SEEK_SET)) {
40 position_ = position;
41 return true;
43 #endif // defined(_WIN32)
44 return false;
47 off_t Tell() const {
48 return position_;
51 private:
52 FILE * const file_;
53 off_t position_;
56 } // namespace ots
58 #endif // OTS_FILE_STREAM_H_