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"
12 // An OTSStream implementation for testing.
13 class FILEStream
: public OTSStream
{
15 explicit FILEStream(FILE *stream
)
16 : file_(stream
), position_(0) {
24 bool WriteRaw(const void *data
, size_t length
) {
25 if (!file_
|| ::fwrite(data
, length
, 1, file_
) == 1) {
32 bool Seek(off_t position
) {
34 if (!file_
|| !::_fseeki64(file_
, position
, SEEK_SET
)) {
39 if (!file_
|| !::fseeko(file_
, position
, SEEK_SET
)) {
43 #endif // defined(_WIN32)
58 #endif // OTS_FILE_STREAM_H_