Shaka Packager SDK
memory_file.h
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FILE_MEDIA_FILE_H_
8 #define MEDIA_FILE_MEDIA_FILE_H_
9 
10 #include <stdint.h>
11 
12 #include <string>
13 #include <vector>
14 
15 #include "packager/file/file.h"
16 
17 namespace shaka {
18 
21 class MemoryFile : public File {
22  public:
23  MemoryFile(const std::string& file_name, const std::string& mode);
24 
27  bool Close() override;
28  int64_t Read(void* buffer, uint64_t length) override;
29  int64_t Write(const void* buffer, uint64_t length) override;
30  int64_t Size() override;
31  bool Flush() override;
32  bool Seek(uint64_t position) override;
33  bool Tell(uint64_t* position) override;
35 
39  static void DeleteAll();
42  static void Delete(const std::string& file_name);
43 
44  protected:
45  ~MemoryFile() override;
46  bool Open() override;
47 
48  private:
49  std::string mode_;
50  std::vector<uint8_t>* file_;
51  uint64_t position_;
52 
53  DISALLOW_COPY_AND_ASSIGN(MemoryFile);
54 };
55 
56 } // namespace shaka
57 
58 #endif // MEDIA_FILE_MEDIA_FILE_H_
shaka::MemoryFile::Flush
bool Flush() override
Definition: memory_file.cc:160
shaka::MemoryFile::Write
int64_t Write(const void *buffer, uint64_t length) override
Definition: memory_file.cc:137
shaka::MemoryFile::Read
int64_t Read(void *buffer, uint64_t length) override
Definition: memory_file.cc:125
shaka::File::file_name
const std::string & file_name() const
Definition: file.h:96
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::MemoryFile::Seek
bool Seek(uint64_t position) override
Definition: memory_file.cc:164
shaka::MemoryFile::Delete
static void Delete(const std::string &file_name)
Definition: memory_file.cc:190
shaka::MemoryFile
Definition: memory_file.h:21
shaka::MemoryFile::Size
int64_t Size() override
Definition: memory_file.cc:155
shaka::File
Define an abstract file interface.
Definition: file.h:28
shaka::MemoryFile::Tell
bool Tell(uint64_t *position) override
Definition: memory_file.cc:172
shaka::MemoryFile::Close
bool Close() override
Definition: memory_file.cc:118
shaka::MemoryFile::Open
bool Open() override
Internal open. Should not be used directly.
Definition: memory_file.cc:177
shaka::MemoryFile::DeleteAll
static void DeleteAll()
Definition: memory_file.cc:186