lin
2025-08-01 633231e833e21d5b8b1c00cb15aedb62b3b78e8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2015 The Chromium OS 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 CHROMIUMOS_WIDE_PROFILING_FILE_READER_H_
#define CHROMIUMOS_WIDE_PROFILING_FILE_READER_H_
 
#include <stdio.h>
 
#include "data_reader.h"
 
namespace quipper {
 
// Read from an input file. Must be a normal file. Does not support pipe inputs.
class FileReader : public DataReader {
 public:
  explicit FileReader(const string& filename);
  virtual ~FileReader();
 
  bool IsOpen() const { return infile_; }
 
  void SeekSet(size_t offset) override { fseek(infile_, offset, SEEK_SET); }
 
  size_t Tell() const override { return ftell(infile_); }
 
  bool ReadData(const size_t size, void* dest) override;
 
  // If there is a failure reading the data from file, |*str| will not be
  // modified.
  bool ReadString(const size_t size, string* str) override;
 
 private:
  // File input handle.
  FILE* infile_;
};
 
}  // namespace quipper
 
#endif  // CHROMIUMOS_WIDE_PROFILING_FILE_READER_H_