Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
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_
static void Delete(const std::string &file_name)
Definition: memory_file.cc:134
const std::string & file_name() const
Definition: file.h:94
static void DeleteAll()
Definition: memory_file.cc:130
bool Open() override
Internal open. Should not be used directly.
Definition: memory_file.cc:112
bool Close() override
Definition: memory_file.cc:62
Define an abstract file interface.
Definition: file.h:26
bool Seek(uint64_t position) override
Definition: memory_file.cc:99
int64_t Write(const void *buffer, uint64_t length) override
Definition: memory_file.cc:79
int64_t Size() override
Definition: memory_file.cc:90
bool Tell(uint64_t *position) override
Definition: memory_file.cc:107
bool Flush() override
Definition: memory_file.cc:95
int64_t Read(void *buffer, uint64_t length) override
Definition: memory_file.cc:67