Shaka Packager SDK
Loading...
Searching...
No Matches
memory_file.h
1// Copyright 2015 Google LLC. 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 <cstdint>
11#include <string>
12#include <vector>
13
14#include <packager/file.h>
15#include <packager/macros/classes.h>
16
17namespace shaka {
18
21class 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 void CloseForWriting() override;
31 int64_t Size() override;
32 bool Flush() override;
33 bool Seek(uint64_t position) override;
34 bool Tell(uint64_t* position) override;
36
40 static void DeleteAll();
43 static void Delete(const std::string& file_name);
44
45 protected:
46 ~MemoryFile() override;
47 bool Open() override;
48
49 private:
50 std::string mode_;
51 std::vector<uint8_t>* file_;
52 uint64_t position_;
53
54 DISALLOW_COPY_AND_ASSIGN(MemoryFile);
55};
56
57} // namespace shaka
58
59#endif // MEDIA_FILE_MEDIA_FILE_H_
static void Delete(const std::string &file_name)
static void DeleteAll()
All the methods that are virtual are virtual for mocking.