Shaka Packager SDK
local_file.h
1 // Copyright 2014 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 PACKAGER_FILE_LOCAL_FILE_H_
8 #define PACKAGER_FILE_LOCAL_FILE_H_
9 
10 #include <stdint.h>
11 
12 #include <string>
13 
14 #include "packager/base/compiler_specific.h"
15 #include "packager/file/file.h"
16 
17 namespace shaka {
18 
20 class LocalFile : public File {
21  public:
25  LocalFile(const char* file_name, const char* mode);
26 
29  bool Close() override;
30  int64_t Read(void* buffer, uint64_t length) override;
31  int64_t Write(const void* buffer, uint64_t length) override;
32  int64_t Size() override;
33  bool Flush() override;
34  bool Seek(uint64_t position) override;
35  bool Tell(uint64_t* position) override;
37 
41  static bool Delete(const char* file_name);
42 
43  protected:
44  ~LocalFile() override;
45 
46  bool Open() override;
47 
48  private:
49  std::string file_mode_;
50  FILE* internal_file_;
51 
52  DISALLOW_COPY_AND_ASSIGN(LocalFile);
53 };
54 
55 } // namespace shaka
56 
57 #endif // PACKAGER_FILE_LOCAL_FILE_H_
shaka::LocalFile::Write
int64_t Write(const void *buffer, uint64_t length) override
Definition: local_file.cc:126
shaka::File::file_name
const std::string & file_name() const
Definition: file.h:96
shaka::LocalFile::Close
bool Close() override
Definition: local_file.cc:104
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::LocalFile::Size
int64_t Size() override
Definition: local_file.cc:138
shaka::LocalFile::Seek
bool Seek(uint64_t position) override
Definition: local_file.cc:161
shaka::LocalFile::Delete
static bool Delete(const char *file_name)
Definition: local_file.cc:199
shaka::LocalFile::Read
int64_t Read(void *buffer, uint64_t length) override
Definition: local_file.cc:114
shaka::LocalFile::Open
bool Open() override
Internal open. Should not be used directly.
Definition: local_file.cc:184
shaka::File
Define an abstract file interface.
Definition: file.h:28
shaka::LocalFile
Implement LocalFile which deals with local storage.
Definition: local_file.h:20
shaka::LocalFile::Tell
bool Tell(uint64_t *position) override
Definition: local_file.cc:170
shaka::LocalFile::LocalFile
LocalFile(const char *file_name, const char *mode)
Definition: local_file.cc:98
shaka::LocalFile::Flush
bool Flush() override
Definition: local_file.cc:156