Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
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_
const std::string & file_name() const
Definition: file.h:94
bool Close() override
Definition: local_file.cc:27
bool Seek(uint64_t position) override
Definition: local_file.cc:84
bool Flush() override
Definition: local_file.cc:79
Define an abstract file interface.
Definition: file.h:26
int64_t Size() override
Definition: local_file.cc:61
static bool Delete(const char *file_name)
Definition: local_file.cc:113
Implement LocalFile which deals with local storage.
Definition: local_file.h:20
int64_t Read(void *buffer, uint64_t length) override
Definition: local_file.cc:37
bool Open() override
Internal open. Should not be used directly.
Definition: local_file.cc:107
int64_t Write(const void *buffer, uint64_t length) override
Definition: local_file.cc:49
bool Tell(uint64_t *position) override
Definition: local_file.cc:93
LocalFile(const char *file_name, const char *mode)
Definition: local_file.cc:21